PROJ-427: reload to re-auth via Cloudflare Access on a 401#129
Merged
Conversation
apiFetch threw a generic Error on any non-2xx response, including a 401 from an expired Cloudflare Access session mid-use — leaving the user stuck on stale UI with no path back to a working session. On 401, force a full page reload so Access can challenge and redirect back once re-authenticated. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018DjSCvRampBsoXiqUwyQGx
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.
Summary
apiFetchthrew a generic error on any non-2xx response, including a 401 from an expired Cloudflare Access session — leaving the user stuck on stale UI with no way back to a working session short of a manual reload.apiFetchnow triggerswindow.location.reload()(and never resolves), forcing a full navigation that Cloudflare Access intercepts at the edge and challenges for fresh login, landing the user back on the same page afterward.Investigation
/api/*and/mcp/*each have their own Access Application set tobypass: everyone(pre-existing since 2026-06-21, not the cause) — enforcement for those paths is entirely the Worker's ownauthMiddleware, which correctly 401s on a stale/invalid session. The frontend just had no handling for that response.PROJ-427
Test plan
pnpm --filter web test— 380 tests pass, including new coverage for the 401 reload pathastro check— 0 errorsbiome checkon changed files — clean🤖 Generated with Claude Code
https://claude.ai/code/session_018DjSCvRampBsoXiqUwyQGx