Hi it seems the super helpful
x-country header is returning DE for all my endpoints.
*The following is irrelevant to the actual problem.*
Example GET to “netlify.com”
content-type: text/html; charset=UTF-8
cache-control: public, max-age=0, must-revalidate
date: Wed, 05 Jul 2023 19:52:24 GMT
server-timing: cr;desc="hit-fresh", ds;dur=3, dc;desc="aws-lhr", cg;desc="global-production", cl;dur=512719, dist;dur=135, tls;desc="reused"
strict-transport-security: max-age=31536000; includeSubDomains; preload
x-cache: Miss from cloudfront
via: 1.1 f33cf28b2f4af4733ccec76b9bf56bc6.cloudfront.net (CloudFront)
I don’t believe this functionality ever existed It should still exist in Edge Functions (and probably Functions, though I’m not 100% sure about the latter).
Hmm it seems that a country code is still returned from my lambda endpoint. I am sending a request from the UK but
x-country is returning
DE (The functions server is in Germany)
x-country based on where the request is coming from or where the request is handled?
FYI the Vercel equivalent is
Seems to be related to proxies according to this:
So I am using lambda functions so proxies shouldn’t be a problem. Also the header can be found in a request it just isn’t for the correct country. I think I have figured the problem out though.
Request sent from Netlify Site to my API (Request is sent via functions hosted in Germany)
API will fetch headers from incoming requests (assuming the country will be DE because the request is coming from a function hosted in Germany)
So to get the country code of the user who sends the request via the Netlify Site, I think the only way is to pass the
x-country header to the API instead of calculating it natively from the API.
Bit confusing but I think that’s the best way to go about it?