I’m using my Nuxt app with cloudflare to get users geo location country (cf-ipcountry) using a middleware. I’ve recently switched to DigitalOcean from Google Cloud App Engine and seems like I’m unable to request cf-ipcountry.
Do you guys have any idea why? Or how i can fix it?
Here’s a sample code:
export default async function ({ req,res }) {
try {
const loc = req.headers['cf-ipcountry']
if (loc === undefined) {
console.log("Unknown")
} else {
console.log(loc)
}
}
catch (err) {
console.log(err)
}
}
Checking the request headers in the DigitalOcean App Logs, I cant even see cf-ipcountry.
Would really appreciate any help. Thanks!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
This comment has been deleted
Hi Did you find a solution to this ?