Detecting user region
Hi,
What is the proper way to get the user's region inside the worker script? Getting the country works fine (cf-ipcountry') but the region does not seem to work with cf-region.
3 Replies
IMO - the most specific you can get within CF is the colo-id "EdgeColoID". otherwise you'll rely on country but in order to get more granual you'd have to do custom geo lookups. def do not recommend utilizing ASNs
Usually what people do for more detailed geolocation is using something like MaxMind.
You can get it off the request object, ex
request.cf.region
https://developers.cloudflare.com/workers/runtime-apis/request/
There's also regionCode, continent, city, country, etc
Example of that information on your ip: https://chaika.dev/
CF"s IP geolocation fields/information is all Maxmind powered, no need to use something external 🙂
I think they include all the geo information maxmind has, besides maybe confidence and some of the non-geoip maxmind fields like connection type