fix(cloudflare): return redirects from cache-facing fetches - #3242
Open
JamesbbBriz wants to merge 1 commit into
Open
fix(cloudflare): return redirects from cache-facing fetches#3242JamesbbBriz wants to merge 1 commit into
JamesbbBriz wants to merge 1 commit into
Conversation
A fetch through the cache-enabled response entrypoint follows redirects by default. When a shared-cache render responds with a redirect, the runtime follows it and re-enters the entrypoint for the redirect target while the response-stage invocation still describes the original URL — so the redirect source re-renders and redirects again, until the runtime's redirect budget is exhausted (TypeError: Too many redirects). Observed on a Payload CMS app whose /admin route redirects unauthenticated visitors to /admin/login: every hop logged another /admin/login render performed with the original /admin invocation, and the page 500ed. Bisected to 35af791 (cloudflare#3168), which routes public traffic through the cache-fronted entrypoint. Set redirect: manual on the cache-facing request so redirect responses are returned to the caller, matching the pre-cloudflare#3168 gateway behavior.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
commit: |
JamesbbBriz
added a commit
to JamesbbBriz/vinext
that referenced
this pull request
Sep 11, 2026
Contributor
Performance benchmarksCompared 0 improved · 0 regressed · 6 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since #3168 (35af791), any route whose shared-cache render responds with a redirect returns
500 TypeError: Too many redirectsto the client.Reproducer: a Payload CMS app whose
/adminroute redirects unauthenticated visitors to/admin/login(a stock Payload setup with zero users). On currentmain,GET /admin500s. On 80c5f59 (the commit before 35af791) it returns307 -> /admin/loginand the login page renders.Root cause
A fetch through the cache-enabled response entrypoint follows redirects by default. When the render responds
307:/admin/login)./admin) — observed via instrumentation: every hop rendered with the originalrequestUrlwhile the entrypoint received the login URL.TypeError: Too many redirects, chain of 20 identical hops in the worker logs).Bisected with repeated single-change deploys of a Payload app: first bad commit is 35af791 (#3168), which routes public traffic through the cache-fronted entrypoint.
Fix
Set
redirect: "manual"on the cache-facing request increateCacheFacingRequest, so redirect responses are returned to the caller — matching the pre-#3168 gateway behavior.Verified on a deployed Payload CMS site (D1/KV/R2, workers cache
cdnAdapter):GET /admin→307to/admin/login(was 500)GET /admin/login→ 200CF-Cache-Status: HITwith the staged pipeline intactTest
Adds a regression test in
cloudflare-cdn-worker.test.tsasserting the cache-facing request carries `redirect: "manual"" and the redirect status passes through the gateway.Fixes #3243