Skip to content

PROJ-427: reload to re-auth via Cloudflare Access on a 401#129

Merged
TAJD merged 1 commit into
mainfrom
fix-401-expired-cf-access-session
Jul 19, 2026
Merged

PROJ-427: reload to re-auth via Cloudflare Access on a 401#129
TAJD merged 1 commit into
mainfrom
fix-401-expired-cf-access-session

Conversation

@TAJD

@TAJD TAJD commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes user-reported 401 issues on the production deployment: apiFetch threw 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.
  • On a 401, apiFetch now triggers window.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

  • Confirmed via user report: session was logged in and in active use, then API calls started failing with 401 (root Access app session_duration is 24h).
  • Checked Cloudflare Access config directly via the API: /api/* and /mcp/* each have their own Access Application set to bypass: everyone (pre-existing since 2026-06-21, not the cause) — enforcement for those paths is entirely the Worker's own authMiddleware, 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 path
  • astro check — 0 errors
  • biome check on changed files — clean

🤖 Generated with Claude Code

https://claude.ai/code/session_018DjSCvRampBsoXiqUwyQGx

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
@TAJD
TAJD merged commit ff895ae into main Jul 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant