// AI Platform Drift
Workers fetch() adds redirect: "error" mode, default on 2026-12-22
Cloudflare developer changelog · published 2026-11-30 00:18 UTC
WHAT CHANGEDCloudflare Workers now supports redirect: "error" in fetch() and Request, which rejects with a TypeError when the server responds with a redirect status (301, 302, 303, 307, or 308) without contacting the redirect destination. This mode is enabled by default for Workers with a compatibility date of 2026-12-22 or later. Workers on earlier compatibility dates can opt in with the fetch_redirect_error flag; Workers on 2026-12-22 or later can opt out with no_fetch_redirect_error.
WHY IT MATTERSExisting Workers that rely on the current default redirect behavior (follow) will reject redirects instead if their compatibility date is set to 2026-12-22 or later, breaking any code that expects fetch() to follow redirects automatically. This affects OAuth flows, API calls, and any upstream services that use redirects as part of their normal operation.
WHAT TO DOBefore setting your Worker's compatibility date to 2026-12-22 or later, test all fetch() calls that might encounter redirects. If your code needs to follow redirects, explicitly set redirect: "follow" in fetch() options, or add the no_fetch_redirect_error compatibility flag to your wrangler.toml or wrangler.json to preserve current behavior.
Model-reported confidence 95% (not measured accuracy)
Primary source ↗
Summary drafted by an AI model and checked by RADAR's rules
Show the reasoning — raw diff, triage verdict, confidence
RAW DIFF
+## Workers - Reject redirects in Workers fetch requests +https://developers.cloudflare.com/changelog/post/2026-11-28-fetch-redirect-error/ +Sat, 28 Nov 2026 00:00:00 GMT + +Cloudflare Workers now supports redirect: "error" in fetch() and Request, completing support for all three redirect modes defined by the WHATWG Fetch Standard ↗︎: follow, manual, and error. +When the server responds with a redirect status (301, 302, 303, 307, or 308), fetch() with redirect: "error" rejects with a TypeError without contacting the redirect destination. It rejects even if the response has no Location header. Non-redirect 3xx responses, such as 304 Not Modified, resolve normally. +Use redirect: "error" to: + +Protect credentials and secrets: Fail closed on OAuth token exchanges, signed webhooks, and API calls carrying sensitive headers (such as Cookie, X-API-Key, or Authorization) so redirects cannot forward headers to another destination. +Prevent server-side request forgery (SSRF) redirect hops: After you validate a user-supplied URL, block redirects to unvalidated hosts. This applies to webhook targets, link previews, and feed fetchers. +Enforce strict API contracts: Catch unexpected redirects (such as an upstream API redirecting to an HTML sign-in page) immediately instead of following them, consuming extra subrequests, and failing later during response parsing. +Share code across runtimes: Use the same redirect: "error" option in Workers and browsers when your code needs to reject redirects. + +src/index.jsjsexport default { +async fetch(request, env) { +try { +const response = await fetch("https://api.example.com/v1/token", { +method: "POST", +headers: { +"X-API-Key": env.API_KEY, +}, +redirect: "error", +}); + +return response; +} catch { +return new Response( +"Upstream request failed or returned an unexpected redirect", +{ +status: 502, +}, +); +} +}, +};src/index.tstsexport default { +async fetch(request, env): Promise<Response> { +try { +const response = await fetch("https://api.example.com/v1/token", { +method: "POST", +headers: { +"X-API-Key": env.API_KEY, +}, +redirect: "error", +}); + +return response; +} catch { +return new Response( +"Upstream request failed or returned an unexpected redirect", +{ +status: 502, +}, +); +} +}, +} satisfies ExportedHandler<{ API_KEY: string }>; +This mode is enabled by default for Workers with a compatibility date of 2026-12-22 or later. To opt in on an earlier compatibility date, add the fetch_redirect_error compatibility flag: +{ +"$schema": "./node_modules/wrangler/config-schema.json", +"compatibility_flags": [ +"fetch_redirect_error" +] +}compatibility_flags = ["fetch_redirect_error"] +For compatibility dates on or after 2026-12-22, add no_fetch_redirect_error to opt out. If you pass a URL to fetch() or new Request(), the default is follow. If you pass an existing Request, both use its redirect mode unless you override it. Incoming requests use manual. +For more information, refer to Redirect handling and the fetch_redirect_error compatibility flag.
HOW IT WAS JUDGED
Triage signals below are model-reported assertions, preserved verbatim; they are not independent arithmetic verification.
| triage verdict | Material (MATERIAL) at 0.92, needed 0.5 |
|---|---|
| triage reasoning | New fetch() redirect mode with default enablement on future compatibility date changes request handling behavior. |
| signals | new API feature: redirect: "error" mode for fetch() · breaking change: enabled by default on compatibility date 2026-12-22 · security-relevant: credential protection, SSRF prevention · execution change: fetch() behavior altered for redirect handling · opt-out required: existing code may need compatibility flag adjustment |
| suppression | — |
| triage model | anthropic/claude-haiku-4.5 ($0.00000) |
| writer model | anthropic/claude-sonnet-4.5 ($0.00000) |