Cloudflare Workers adds a fetch mode that rejects redirects
Brief
Workers can now reject redirects instead of following them, helping prevent sensitive requests from reaching an unintended destination.
Behavior
- Set redirect: "error" in fetch() or Request to reject redirect responses with a TypeError without contacting the redirect destination.
- This applies to status codes 301, 302, 303, 307, and 308, even when there is no Location header. Other 3xx responses, such as 304, resolve normally.
Availability
- The mode is enabled by default for Workers with a compatibility date of 2026-12-22 or later.
- Earlier compatibility dates can opt in with the fetch_redirect_error flag; dates from 2026-12-22 can opt out with no_fetch_redirect_error.
Generated by AI from the original article. Check the source for full details.