diff --git a/.changeset/quiet-roses-design.md b/.changeset/quiet-roses-design.md new file mode 100644 index 000000000..c2a41f432 --- /dev/null +++ b/.changeset/quiet-roses-design.md @@ -0,0 +1,5 @@ +--- +'@cloudflare/next-on-pages': patch +--- + +Changes to the x-vercel-ip headers to bring their structure in line with deployments to Vercel. diff --git a/packages/next-on-pages/templates/_worker.js/utils/request.ts b/packages/next-on-pages/templates/_worker.js/utils/request.ts index 6ab1b4e1c..43dc00232 100644 --- a/packages/next-on-pages/templates/_worker.js/utils/request.ts +++ b/packages/next-on-pages/templates/_worker.js/utils/request.ts @@ -8,17 +8,14 @@ export function adjustRequestForVercel(request: Request): Request { const adjustedHeaders = new Headers(request.headers); if (request.cf) { - adjustedHeaders.append('x-vercel-ip-city', request.cf.city as string); - adjustedHeaders.append('x-vercel-ip-country', request.cf.country as string); - adjustedHeaders.append( + adjustedHeaders.set('x-vercel-ip-city', request.cf.city as string); + adjustedHeaders.set('x-vercel-ip-country', request.cf.country as string); + adjustedHeaders.set( 'x-vercel-ip-country-region', request.cf.region as string, ); - adjustedHeaders.append( - 'x-vercel-ip-latitude', - request.cf.latitude as string, - ); - adjustedHeaders.append( + adjustedHeaders.set('x-vercel-ip-latitude', request.cf.latitude as string); + adjustedHeaders.set( 'x-vercel-ip-longitude', request.cf.longitude as string, );