This site is not affiliated with or endorsed by Cloudflare, Inc. It showcases deployable experiments across most Cloudflare products.

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.

Earth at night seen from space with city lights
Photo by NASA on Unsplash

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

ProductRoleDocs
WorkersRead and expose request.cfEdge runtime
Request cf propertiesGeo / network / TLS metadataRuntime API
Cloudflare RadarEnrich ASN / internet insightsRadar
Cloudflare Radar APIProgrammatic queriesAPI
Rate limiting / Worker limitersAbuse controls using ASN signalsWAF / Workers
Bot management signals (plan-dependent)Bot score fields when enabledBots

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):

FieldUse
countryContent licensing, currency defaults
coloSupport “which POP served this?”
asnAbuse review, VPN heuristics
timezoneLocalize timestamps
city / region (when present)Coarse localization
TLS fieldsDebug 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

  1. Locale bootstrap - default language/currency from country, allow override
  2. Abuse signals - log ASN + path for review; pair with Rate Limiter Demo concepts or WAF rate limiting
  3. Support tooling - show customers which colo served an error page
  4. Radar enrichment - ask network questions via Radar One Question against Cloudflare Radar
  5. 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 country as 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

  1. Skim IncomingRequestCfProperties
  2. Open Where Am I
  3. One-click Deploy or run with Wrangler
  4. Hit the root endpoint from two networks
  5. 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

  1. List which request.cf fields you actually need - drop the rest.
  2. Validate field presence in production (local wrangler can differ).
  3. Document VPN/carrier caveats in UX copy.
  4. Keep PII out of analytics; prefer country/colo/ASN aggregates.
  5. 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

Cloudflare Experiments is an independent open-source catalog - not affiliated with Cloudflare, Inc.