From 4bd4c19220c98eea2286b969c169f4e6d122e977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E6=96=B9=E6=B7=9E?= Date: Mon, 29 Jul 2024 18:10:11 +0200 Subject: [PATCH] Use regionCode instead of region (#838) --- .changeset/curly-weeks-sin.md | 5 +++++ packages/next-on-pages/templates/_worker.js/utils/request.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/curly-weeks-sin.md diff --git a/.changeset/curly-weeks-sin.md b/.changeset/curly-weeks-sin.md new file mode 100644 index 000000000..4dc270fb0 --- /dev/null +++ b/.changeset/curly-weeks-sin.md @@ -0,0 +1,5 @@ +--- +'@cloudflare/next-on-pages': minor +--- + +Use `request.cf.regionCode` for `x-vercel-ip-country-region` for keeping behavior consistent with documentation 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 778b72733..daff28a42 100644 --- a/packages/next-on-pages/templates/_worker.js/utils/request.ts +++ b/packages/next-on-pages/templates/_worker.js/utils/request.ts @@ -17,7 +17,7 @@ export function adjustRequestForVercel(request: Request): Request { adjustedHeaders.set('x-vercel-ip-country', request.cf.country as string); adjustedHeaders.set( 'x-vercel-ip-country-region', - request.cf.region as string, + request.cf.regionCode as string, ); adjustedHeaders.set('x-vercel-ip-latitude', request.cf.latitude as string); adjustedHeaders.set(