PuppyIP Resource Center
Cloud Operations 5 min Published 2026-12-01

How to reject redirects in Cloudflare Workers fetch requests

Cloudflare Workers now supports redirect: "error". If an upstream call should receive a direct response, check its Worker’s compatibility date or flag, then select error for that call.

Cloudflare Workers Fetch API HTTP Redirects Compatibility Date

Service eligibility and regional restrictions

PuppyIP serves only compliant overseas businesses and their authorized personnel. Proxy services are not available in mainland China. The service may only be used for lawful business activities outside mainland China. Use of this service within mainland China is prohibited.

Hosting a proxy IP or server overseas does not change these restrictions. The service must not be provided to end users in mainland China through relaying, forwarding, sharing or resale. Before use, read the Terms of Service.

Key Takeaways

  • The mode works with fetch() and Request. A 301, 302, 303, 307 or 308 rejects with TypeError before the Worker contacts the redirect destination.
  • Workers dated December 22, 2026 or later support the mode by default. Earlier compatibility dates can enable fetch_redirect_error.
  • Support makes the mode available for individual calls. A URL string defaults to follow. When you construct a new Request from an existing one, it inherits the original mode unless you set a different one.
  • Test a direct 200 and a controlled 302. An unsupported mode, an upstream redirect and a network failure can all surface as request errors.

Why do the compatibility date and request setting both matter?

Cloudflare announced support for the third Fetch redirect mode on November 28. The Worker’s compatibility date determines whether the runtime recognizes it. It is enabled by default for compatibility dates from December 22, 2026. For an earlier date, use the fetch_redirect_error flag to test this change on its own.

Find the effective compatibility_date and compatibility_flags for the target environment in your Wrangler configuration. Cloudflare documents no_fetch_redirect_error for opting out on a date where support is enabled by default. Check which flags the deployment uses before selecting error for a specific upstream call.

Which upstream responses cause a rejection?

The Worker stops at 301, 302, 303, 307 or 308 even when the response leaves out Location. Cloudflare treats 304 Not Modified as an ordinary response for this mode, so preserve handling for conditional cache requests.

For example, an internal API expected to return JSON might begin redirecting to a sign-in page after a deployment. An error-mode request enters its failure path. Record the environment, the upstream service name and the outcome without logging secrets, authentication headers or credential-bearing URLs.

When should a request use manual or follow?

Use manual when you need to read the redirect status or inspect Location. Use error for an operation that accepts only a direct response. If the operation deliberately follows an upstream redirect, keep its intended redirect policy and check how it handles authorization across the redirects.

Passing a URL directly to fetch or Request still defaults to follow. A new Request made from an existing Request inherits its mode unless you override it. A request received by Workers starts in manual mode, so check the object you actually use for the upstream call.

How do you verify which path the request took?

In an isolated environment, use the intended setting for an authorized test upstream that returns 200, then try a controlled 302 endpoint. Confirm the direct call succeeds and the redirect enters the failure path. Check the controlled destination’s logs to verify it did not receive a second request.

If the direct request fails too, inspect the runtime and flag first. With support disabled, Request construction throws early and fetch can reject before sending a request. After confirming support, investigate a network error separately from an upstream response status.

Sources

Frequently Asked Questions

Do all Workers start rejecting redirects on December 22?

The compatibility date enables support for error mode in the runtime. The outgoing request still needs to select its intended redirect mode.

Does TypeError prove the server sent a 302?

The error type alone does not establish that. Check the Worker configuration and, in a controlled test, use manual to inspect the upstream status and Location first.