Cloudflare Workers finally supports fetch’s ‘error’ redirect mode
Workers’ fetch() and Request can now reject redirects outright, the last of the three WHATWG Fetch Standard modes, closing a path used for credential leaks and SSRF.
Cloudflare Workers now supports the redirect: "error" option in fetch() and Request, completing all three WHATWG Fetch Standard redirect modes. Workers has had follow and manual for years; error was the one still missing.
With redirect: "error", a fetch that hits a 301, 302, 303, 307 or 308 response rejects immediately with a TypeError, without following the redirect, even when there’s no Location header. That matters because a followed redirect can carry sensitive headers like Cookie, Authorization or X-API-Key to a host you never intended to call, and redirect-chasing is one of the standard ways an SSRF attack hops from a validated host to an internal one.
The mode is on by default for Workers with a compatibility date of 2026-12-22 or later. Before that date, opt in with a compatibility flag:
compatibility_flags = ["fetch_redirect_error"]
After 2026-12-22, add no_fetch_redirect_error instead if you need to opt back out.
Why it matters: if your Worker proxies requests to third-party APIs or user-supplied URLs, you can now reject an unexpected redirect outright instead of hand-rolling manual handling to inspect the response yourself. It also means code written against this part of the Fetch standard behaves the same in a Worker as it does in a browser.