Skip to content

Commit

Permalink
refactor: Update DonateWithPix component to handle multiple country h…
Browse files Browse the repository at this point in the history
…eaders

This commit updates the DonateWithPix component to handle multiple country headers. Previously, it only checked the "X-Vercel-IP-Country" header, but now it also checks the "CF-IPCountry" header. The country is determined by the first non-null value found in the headers. If no country is found, it defaults to "XX".
  • Loading branch information
yanquisalexander committed Aug 30, 2024
1 parent 77daf75 commit 3d24691
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/DonateWithPix.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
---
import ExternalLink from "@/icons/ExternalLink.astro";
const country = Astro.request.headers.get("X-Vercel-IP-Country") ?? "BR";
const countryHeaders = [
"X-Vercel-IP-Country",
"CF-IPCountry",
]
const country = countryHeaders
.map((header) => Astro.request.headers.get(header))
.find((country) => country) ?? "XX";
const discardedPixBannerAt = Astro.cookies.get("discardedPixBannerAt");
Expand Down

0 comments on commit 3d24691

Please sign in to comment.