[🐛 Bug]: Compat: Header values for x-vercel-ip-* headers are appended instead of replaced. #507
Closed
1 task done
Labels
bug
Something isn't working
next-on-pages environment related information
System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Sat, 23 Sep 2023 22:55:13 +0000
CPU: (20) x64 13th Gen Intel(R) Core(TM) i5-13600K
Memory: 63 GB
Shell: /usr/bin/zsh
Binaries:
Node: 18.12.0
Bun: 1.0.4
pnpm: 7.25.0
Yarn: 1.22.19
npm: 9.2.0
Package Manager Used: npm
Relevant Packages:
@cloudflare/next-on-pages: 1.6.3
vercel: N/A
next: 13.5.4
Description
The header rewrites produce different behavior from running the NextJS application on Vercel.
If a client sends a request with the header
x-vercel-ip-city: Atlantis
to a deployment hosted on Pages, the API route will see the following header:x-vercel-ip-city: Atlantis, London
(assuming the user lives in London).Meanwhile, the same application hosted on Vercel will see the header as
x-vercel-ip-city: London
.Reproduction
Create a next API route with the following code:
Deploy it to both Vercel and Pages, and send a request with the
x-vercel-ip-city: Atlantis
header set.curl -H "x-vercel-ip-city: Atlantis" https://example.com/apiroute | jq '.h["x-vercel-ip-city"]'
Observe that the response differs between Vercel and Pages.
Pages Deployment Method
Pages CI (GitHub/GitLab integration)
Pages Deployment ID
https://0086b0c1.header-accuracy-test.pages.dev
Additional Information
Using
set
instead ofappend
in https://github.com/cloudflare/next-on-pages/blob/main/packages/next-on-pages/templates/_worker.js/utils/request.ts should fix this problem and make the behavior inline with deployments on Vercel.Would you like to help?
The text was updated successfully, but these errors were encountered: