is undefined

The documentation says:

In addition to the information available on the Request object, such as headers, Cloudflare provides additional attributes of the request using the object.

Attributes available on :

  • country : the two letter country code on the request (this is the same value as the one provided by the CF-IPCountry header)
  • colo : the three letter airport code of the colo the request hit.

When I try to console.log and it returns undefined.

some of the headers not available in the debug mode only in production, I use it like so(saw it somewhere in the docs):
( || {}).colo

1 Like

I wish that was mentioned in the documentation! Thanks for the info


also sometimes in rare cases country can return undefined so prepare for that

1 Like

Another solution is to just write it like this request?.cf?.colo
That way it shows undefined whenever it is not available

1 Like

Try the following (I have not tried it!)

const country = request.headers.get(‘cf-ipcountry’)
console.log('Country: '+country);

const city =
console.log('City: '+city);

The same for values below:

const connectingip = request.headers.get(‘cf-connecting-ip’)
const city =
const timezone =
const region =
const regionCode =
const asOrganization =
const postalCode =