#Country code issue
1 messages · Page 1 of 1 (latest)
Hi @empty hornet. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
The x-vercel-ip-country header is a two-character ISO 3166-1 (https://en.wikipedia.org/wiki/ISO_3166-1) country code that represents the country associated with the location of the requester's public IP address. This header is included with deployments on Vercel's Edge Network.
If you're not seeing the expected country code, there could be a few reasons:
-
The IP address may be associated with a different country. IP geolocation is not always 100% accurate and can sometimes be associated with the wrong country.
-
If you're testing locally, the geolocation headers will not be set. You can only view geolocation information after making a deployment and reading the incoming request headers.
-
There might be an issue with the way you're accessing the header. If you're using Next.js, you can access the header using the
headers()function from Next.js. Here's an example:
import { headers } from 'next/headers'
export default function Page() {
const countryCode = headers().get('x-vercel-ip-country') || 'US'
// rest of code
}
If you're still having issues, you might want to consider reaching out to Vercel support for further assistance.
Sources:
- Vercel Edge Network Headers (https://vercel.com/docs/edge-network/headers)
- Vercel Guide on Geolocation IP Headers (https://vercel.com/guides/geo-ip-headers-geolocation-vercel-functions)
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@empty hornet kapa.ai is still learning and improving, please let us know how it did by reacting below