๐๐ฃ ๐๐ฒ๐ผ๐น๐ผ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐ช๐ถ๐๐ต ๐ญ๐ฒ๐ฟ๐ผ ๐๐ ๐๐ฒ๐ฟ๐ป๐ฎ๐น ๐๐ฃ๐๐
Stop using geo APIs. Stop paying for keys. Stop adding lag.
Cloudflare Workers has a cf object. It gives you user data at the edge.
You get:
- City and country
- ISP and ASN
- Timezone and coordinates
- HTTP protocol
- TLS version
- TCP round trip time
No lookups. No external servers. No keys. User IPs stay private. No third party sees them.
Keep these tips in mind:
- You get coordinates as strings. Convert them to numbers.
- Some fields stay empty. Check for nulls.
- EU country data uses the string 1. It is not a boolean.
- Local dev shows empty objects. Test in preview.
- City data lacks precision. Use country for reliability.
Use request.cf. Your data is already there.
Source: https://dev.to/kamazaki/ip-geolocation-with-zero-external-apis-the-cloudflare-workers-cf-object-16e