Request.cf is undefined


#1

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 request.cf object.

Attributes available on request.cf :

  • 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 request.cf.colo and request.cf.country it returns undefined.


#3

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


#4

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


#5

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