Blog17 min read
Edge geolocation with request.cf on Cloudflare Workers
Deep guide to Cloudflare request.cf - country, colo, ASN, TLS, bot score signals - product patterns, privacy, Radar pairing, and the Where Am I experiment.
Every request that hits a Cloudflare Worker can expose rich network metadata on request.cf (IncomingRequestCfProperties): country, colo, ASN, timezone, TLS version, and more. For many personalization, compliance, and debugging features, that is enough - no third-party geo IP database required.
The Where Am I experiment returns those fields as JSON so you can explore what Cloudflare attaches in your colo and copy the pattern into products.
Cloudflare products in this pattern
| Product | Role | Docs |
|---|---|---|
| Workers | Read and expose request.cf | Edge runtime |
Request cf properties | Geo / network / TLS metadata | Runtime API |
| Cloudflare Radar | Enrich ASN / internet insights | Radar |
| Cloudflare Radar API | Programmatic queries | API |
| Rate limiting / Worker limiters | Abuse controls using ASN signals | WAF / Workers |
| Bot management signals (plan-dependent) | Bot score fields when enabled | Bots |
What you get without a geo database
Typical fields teams use (availability can depend on request path and account features - always check the live object):
| Field | Use |
|---|---|
country | Content licensing, currency defaults |
colo | Support “which POP served this?” |
asn | Abuse review, VPN heuristics |
timezone | Localize timestamps |
city / region (when present) | Coarse localization |
| TLS fields | Debug modern client requirements |
Treat values as hints, not legal identity. VPNs, mobile carriers, and corporate egress will skew country. Document that in product UX and privacy policies.
The smallest useful API
Where Am I is intentionally tiny:
GET / → JSON of selected request.cf fields (+ request basics)Ideal for:
- Teaching how edge context works on Workers
- Debugging “why is this user in the wrong locale?”
- Smoke-testing deployments from different networks
curl -fsSL https://<your-worker>/ | jq .Call it from home, a phone hotspot, and a cloud shell - watch colo and country change.
Product patterns on top of request.cf
- Locale bootstrap - default language/currency from
country, allow override - Abuse signals - log ASN + path for review; pair with Rate Limiter Demo concepts or WAF rate limiting
- Support tooling - show customers which colo served an error page
- Radar enrichment - ask network questions via Radar One Question against Cloudflare Radar
- Latency maps - compare POPs with Multi-POP Latency Map
Privacy and compliance notes
- Prefer coarse fields (
country,colo) over storing raw IPs when possible - Declare what you log; set retention
- Do not treat
countryas GDPR “adequate” proof of residency alone - Bot-related scores may be plan-gated - see Bots documentation
Local vs production
request.cf behavior can differ in local wrangler versus production. Always validate field presence on a deployed Worker before building hard dependencies. The Workers Request docs are the source of truth for property names.
Deploy Where Am I
- Skim IncomingRequestCfProperties
- Open Where Am I
- One-click Deploy or run with Wrangler
- Hit the root endpoint from two networks
- Copy only the fields your product needs
You learn request.cf with a live API instead of reading property tables alone - then keep Workers as the vehicle and Cloudflare’s edge metadata as the product capability you are actually shipping.
Production checklist
- List which
request.cffields you actually need - drop the rest. - Validate field presence in production (local
wranglercan differ). - Document VPN/carrier caveats in UX copy.
- Keep PII out of analytics; prefer country/colo/ASN aggregates.
- Combine with Radar only when enrichment is worth the extra call.
FAQ
Is country GDPR-grade location proof?
No. Treat it as a hint for defaults, not legal residency evidence.
Why is colo null sometimes?
Not every execution path exposes every property. Guard with optional chaining and defaults. See IncomingRequestCfProperties.
Related experiments
These deployable references implement the patterns in this article. Open the docs for API details, then Deploy or clone the source.
- Where Am I? - Return Cloudflare request.cf geolocation, colo, ASN, and edge metadata - where-am-I API for Workers and agents
- Radar One Question - Ask Cloudflare Radar one fact about a domain rank or ASN org/location - Internet intelligence API demo for agents
- Multi-PoP Latency Map - Measure fetch latency and report the Cloudflare colo that served the Worker - edge PoP latency visibility for any URL
- Rate Limiter Demo - Native Workers Rate Limiting binding with 429 responses and usage visualization - protect APIs at the edge without Redis