Skip to content

Commit

Permalink
Fix city header encoding (RFC3986) (#789)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcojakob authored May 19, 2024
1 parent 2d55e8f commit c2b173c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/city-header-encoding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cloudflare/next-on-pages': minor
---

Fix: The city name for the location of the requester's public IP address must be encoded according to RFC3986.
5 changes: 4 additions & 1 deletion packages/next-on-pages/templates/_worker.js/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export function adjustRequestForVercel(request: Request): Request {
const adjustedHeaders = new Headers(request.headers);

if (request.cf) {
adjustedHeaders.set('x-vercel-ip-city', request.cf.city as string);
adjustedHeaders.set(
'x-vercel-ip-city',
encodeURIComponent(request.cf.city as string),
);
adjustedHeaders.set('x-vercel-ip-country', request.cf.country as string);
adjustedHeaders.set(
'x-vercel-ip-country-region',
Expand Down

0 comments on commit c2b173c

Please sign in to comment.