Skip to content

fix(web): sign in again when an auth proxy's session ends - #216

Merged
mathieuletyrant merged 2 commits into
mainfrom
claude/snag-pwa-cloudflare-session-t9uc85
Nov 23, 2026
Merged

mathieuletyrant merged 2 commits into
mainfrom
claude/snag-pwa-cloudflare-session-t9uc85

Conversation

@mathieuletyrant

@mathieuletyrant mathieuletyrant commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Closes #215

What

The Connect transport now uses its own fetch (fetchThroughAuthProxy), which sends each call with redirect: "manual". If a call comes back as a redirect, the page reloads, at most once a minute. The browser then follows the auth proxy to its sign-in page.

Nothing checks for Cloudflare. This works for any auth proxy that redirects to its sign-in page: Cloudflare Access, Authelia, Authentik, oauth2-proxy… Without a proxy, the redirect path never runs.

Why

Found with Cloudflare Access. Once its session ends, Access redirects every request to its sign-in page, which is on another domain. A page's fetch cannot follow that redirect. The web UI kept open on the Home Screen then only showed errors until it was reloaded by hand. A full page load was never affected, because the browser follows the redirect itself.

New notions, in plain words

  • redirect: "manual": the fetch does not follow a redirect. It returns a placeholder answer whose type is "opaqueredirect". Spotarr's API never redirects, so that answer always means the proxy in front wants a new sign-in.
  • The once-a-minute guard (a time in sessionStorage): if signing in keeps failing, the page does not reload in a loop.
  • The as typeof fetch cast: Bun's types add fetch.preconnect, which a browser fetch never uses.

Checks

  • pnpm check passes locally
  • Traps found on the way are recorded in AGENTS.md (none)

Also checked in Chromium against a fake auth proxy that redirects with a 302 to another origin: after the session "expired", submitting the login form reloaded the page and landed on the fake sign-in page.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MqWWDWYeR6E8VJqWwNY7wg

With Access's session expired, every API call is redirected to the Access
sign-in on another domain, which a fetch cannot follow: the web UI, kept
open on the Home Screen, only showed errors until it was reloaded by hand.

The transport's fetch uses `redirect: "manual"`. A redirect (Spotarr's API
never sends one) reloads the page, at most once a minute, and the browser
follows it to the sign-in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqWWDWYeR6E8VJqWwNY7wg
… Cloudflare Access

The reload works for any auth proxy that redirects to its sign-in
(Cloudflare Access, Authelia, Authentik, oauth2-proxy…): nothing in it
checks Cloudflare. The names and comments now say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MqWWDWYeR6E8VJqWwNY7wg
@mathieuletyrant mathieuletyrant changed the title fix(web): sign in again when the Cloudflare Access session ends fix(web): sign in again when an auth proxy's session ends Nov 23, 2026
@mathieuletyrant
mathieuletyrant merged commit e06c0bb into main Nov 23, 2026
1 check passed
@mathieuletyrant
mathieuletyrant deleted the claude/snag-pwa-cloudflare-session-t9uc85 branch November 23, 2026 07:24
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.

Web UI stuck on errors once the Cloudflare Access session ends

2 participants