Codiatech Blog
Rejecting Unexpected Outbound API Redirects in Cloudflare Workers
How Cloudflare Workers rejects unexpected outbound redirects, when 304 responses resolve normally, and what to verify before deploying an API redirect policy.

Decide Which Destinations an Integration Can Call
A partner API can return a redirect during an endpoint migration or after a routing change. For an integration that sends customer data, exchanges tokens, or attaches an API key, following that redirect may take the request outside the destination the team approved. An outbound policy gives the caller a clear rule. If a particular operation is tied to a known endpoint, the client can reject an unexpected redirect and give the integration owner a chance to verify the change.
What Workers Does When a Redirect Arrives
Cloudflare Workers supports redirect: "error" in fetch() and Request. With that mode selected, fetch() contacts the original endpoint. A response with status 301, 302, 303, 307, or 308 causes the promise to reject with a TypeError. The redirect destination receives no request from that call. The same rejection occurs when the response omits the Location header.
A 304 Not Modified response can tell a conditional client to continue using its cached representation. Because 304 does not trigger redirect handling, the fetch promise resolves and the caller can apply its cache logic. Cloudflare’s flag documentation also lists 300 as a response that resolves normally. Base the integration’s policy on the specific response semantics instead of treating the entire 3xx range as redirects.
Compatibility Controls Support for the Mode
Workers makes the mode available by default for compatibility dates on or after December 22, 2026. For an earlier date, fetch_redirect_error enables it. On or after that date, no_fetch_redirect_error disables it. A URL passed directly to fetch() or new Request() still defaults to follow. When given an existing Request, both use its redirect mode unless the caller overrides it. If support is disabled, selecting the mode can produce a TypeError before a request goes out. Cloudflare’s release announcement and Workers compatibility flag documentation describe these settings.
Verify the Policy Alongside the Business Workflow
For a sensitive integration, document the approved endpoint, who can authorize a change, and what the business workflow should do when a call stops. An order sync, for example, needs a clear way for operators to identify records awaiting review. A planned API move can then go through the same approval and deployment process as any other change to that connection.
Acceptance tests should cover a successful call to the approved endpoint, rejection of an unexpected redirect, and normal handling of a 304 where the workflow uses conditional requests. Verify the behavior with the compatibility date and flags you intend to deploy. Include the caller’s failure path in the review so a rejected call cannot silently become a request to an alternate destination.

Make a Stopped Call Actionable
A TypeError alone cannot establish that the partner returned a redirect. Give operators the integration name, environment, and a correlation identifier so they can investigate through their usual support process. Keep credentials and sensitive payloads out of logs. Codiatech brings endpoint selection, permissions, error handling, and monitoring into the same system integration engagement.
Primary source: developers.cloudflare.com