API Endpoint
GET /redirect-chain
Follow redirects for a URL and return the chain of hops.The URL to trace. Use a full URL (
https://cloudflare.com) or hostname (example.com). Only http and https are allowed.Example Request
Success Response
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
example.com → 301 → www.example.com → 302 → final.example.com → 200.
Error Responses
400 Bad Request — Missing or invalidurl (wrong scheme or malformed):
Location or exceeds the hop limit, the response is still 200 with the chain collected so far and an error message in the body.
Deployment
Deploy
Follow the deployment wizard to deploy the Worker to your Cloudflare account. No additional configuration or bindings required.
Local Development
http://localhost:8787/redirect-chain?url=https://cloudflare.com
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
Cloudflare Features Used
- Workers — Edge compute runtime
- Fetch API — HTTP requests with
redirect: "manual"to capture each hop - Edge Networking — Redirect chain observed from Cloudflare’s global network