Test Cloudflare request.cf.country redirects from another country
If a Cloudflare Worker reads request.cf.country, the value comes from Cloudflare's view of the incoming request origin. Changing browser locale, a query parameter, or a local geolocation setting does not change that value unless your own Worker code explicitly uses those inputs.
To reproduce a country-dependent redirect, keep the request itself fixed and change only the network route. Then compare the response Cloudflare returns for the same URL, method, headers, cookies, authentication, query parameters, and body.
Use this workflow only when the Worker actually reads request.cf.country or another request-origin signal. It is not a claim that every Cloudflare redirect is country-based.
How request.cf.country affects the Worker
Cloudflare's official country-code redirect example reads:
const country = request.cf.country; The Worker can then choose a redirect target from that value and return it with Response.redirect(...).
Official references:
- — Country-code redirect example
- — Workers Request API
- — Worker redirect example
- — Static-assets redirects
This page applies only when your Worker logic actually reads request.cf.country or another request-origin signal.
Test the same request from another country
Start with the exact request that reproduces the problem. Do not simplify headers, cookies, authentication, query parameters, or method unless you are deliberately testing those variables.
Then run the same request directly and through the country routes you want to compare.
Replace https://your-worker.example/path with the Worker URL you are debugging.
Direct
curl -sSI https://your-worker.example/path From the US
shellroute run US -- curl -sSI https://your-worker.example/path From Germany
shellroute run DE -- curl -sSI https://your-worker.example/path For a redirect, compare at least the HTTP status code, the Location header, and any application-specific headers your Worker adds.
Note: curl -sSI sends a HEAD request. A Worker can behave differently for HEAD than for the GET that real users send. If HEAD does not reproduce the bug, retry with a plain GET (curl -sS) before concluding country is not the factor.
If you need to compare body content, use the same request without -I and compare a safe body fingerprint rather than logging sensitive responses.
Keep the test controlled
Before interpreting the result, keep the URL and method, headers, cookies/authentication, query parameters, request body, and client options identical across runs. Changing several inputs at once makes it impossible to know whether country was the reason the response changed.
Three properties of proxy testing to keep in mind:
- — Each run may use a different IP. A new session picks from the available pool, so re-running the same command can exit from a different address with different reputation. Inconsistent results between runs are expected, not a bug.
- — Residential and datacenter IPs behave differently. CDNs commonly treat hosting ranges more suspiciously than residential ones. A test that gets challenged on datacenter but passes on residential says something about the range's reputation, not about the country.
- — Geo-IP databases disagree and lag. The selected route and Cloudflare's country classification can come from different data sources. If they disagree, record the mismatch as part of the result instead of assuming either source is definitive.
If you are reproducing the same kind of origin-dependent behavior in browser automation, see Playwright geolocation vs network IP.
How to interpret the result
Different status or Location by route: request origin is one of the inputs affecting the behavior you reproduced. If the Worker reads request.cf.country, inspect the country map, fallback branch, and redirect logic next.
Same response from every route: this request did not reproduce a country-dependent difference at that moment. That does not prove the Worker is correct. Check whether the tested countries are in your redirect map, whether another condition runs before the country check, and whether cookies, authentication, cache state, path, or method are part of the original bug.
Worker logic is different from _redirects
Do not confuse Worker code with static-asset _redirects rules. Cloudflare's current static-assets documentation says redirect-by-country is not supported in _redirects, and _redirects rules are not applied to requests served by Worker code. If your country logic lives in a Worker, debug the Worker path itself rather than expecting _redirects to reproduce it.
For the general controlled-comparison method, use the request replay recipe.
Need to run the same request through another country?
Configure the route with the Shellroute Quickstart