How can I determine the visitors country in my Gatsby app?

I’m trying to determine which country a visitor comes from in my Gatsby app and setting the parameter value as a cookie. Understand there should be a “x-country” header available but it seems the header is not being sent when connecting to my app.

Any help would be appreciated.

Solved this by setting a cookie with a edge function

Could you please share the function code?

Sorry, did not see your reply. I’m sure you solved it by now but will leave my solution here for anyone else looking:

Thanks for sharing zamson. (:

1 Like