This site is not affiliated with or endorsed by Cloudflare, Inc. It simply showcases experiments built using Cloudflare services.
Cloudflare Experiments

Edge Redirect Simulator

Show redirect chains for any URL from Cloudflare's edge-each hop and status code

Show redirect chains for any URL from Cloudflare's edge. The Worker follows HTTP redirects (301, 302, 303, 307, 308) and returns each hop with its status code, so you can see exactly how a URL resolves.

API Reference

GET /redirect-chain

Follow redirects for a URL and return the chain of hops.

Prop

Type

Example Request

curl "https://your-worker.workers.dev/redirect-chain?url=https://example.com"

Success Response

chain array

Array of objects, one per hop in the redirect chain.

url string

The URL at this hop (after redirect, if any).

status number

HTTP status code at this hop (e.g. 301, 302, 200).

error string (optional)

Present if the chain was truncated-e.g. missing Location header, redirect loop, or max redirects exceeded. Response is still 200 with the chain collected so far.

Example Response

{
  "chain": [
    { "url": "https://example.com/", "status": 301 },
    { "url": "https://www.example.com/", "status": 302 },
    { "url": "https://final.example.com/", "status": 200 }
  ]
}

Display form: example.com → 301www.example.com → 302final.example.com → 200.

Error Responses

400 Bad Request - Missing or invalid url (wrong scheme or malformed):

{
  "error": "Missing or invalid query parameter: url",
  "code": "INVALID_URL"
}

500 Internal Server Error - Uncaught error (e.g. fetch failure):

{
  "error": "Internal error message",
  "code": "INTERNAL_ERROR"
}

If the chain hits a redirect with no Location or exceeds the hop limit, the response is still 200 with the chain collected so far and an error message in the body.

Use Cases

  • Debug redirects - See the full chain from short URL or vanity domain to final destination
  • SEO and canonicalization - Verify 301/302 chains and final URLs
  • Security and compliance - Audit where redirects lead before clicking
  • Integration testing - Confirm redirect behavior from the edge

Limitations

  • Stops after 20 redirects to prevent infinite loops
  • Does not follow meta refresh or JavaScript-based redirects
  • Fetch timeout applies per hop on slow origins
  • Reports redirect chain from the edge; results may differ from a browser

Deployment

Deploy

Follow the deployment wizard to deploy the Worker to your Cloudflare account. No additional configuration or bindings required.

Test your deployment

curl "https://your-worker.workers.dev/redirect-chain?url=https://cloudflare.com"

Local Development

cd apps/experiments/edge-redirect-simulator
npm install
npm run dev

Then open: http://localhost:8787/redirect-chain?url=https://cloudflare.com

Cloudflare Features Used

  • Workers - Edge compute runtime
  • Fetch API - HTTP requests with redirect: "manual" to capture each hop
  • Edge network - Redirect chain observed from Cloudflare's global network

Next Steps

On this page