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!

Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!