Skip to content

Phones: sign in again when Cloudflare Access expires instead of hanging - #5

Merged
EveAeternam merged 1 commit into
mainfrom
claude/phone-cloudflare-login-z0wndy
Oct 13, 2026
Merged

EveAeternam merged 1 commit into
mainfrom
claude/phone-cloudflare-login-z0wndy

Conversation

@EveAeternam

Copy link
Copy Markdown
Collaborator

Requested by Evie · project thread

What changed and why

Before: on a phone using ai.shellb.app, once the Cloudflare Access session ran out every API call got a redirect to Cloudflare's login on another site. A fetch can't follow that, so the app showed "Can't reach Shell:B. Reconnecting…" forever, and the only way out was opening the site in Chrome to log in again. The manifest was also fetched without cookies, so Access turned it away and phones couldn't install Shell:B as a real app.

After: when a request fails, ui/src/net.ts asks /api/auth/me without following redirects. If the answer is a redirect (or a 401/403, which Shell:B's own /api/auth/me never sends), it reloads the page so Cloudflare's login appears right inside the app, then comes back. A sessionStorage guard stops reload loops. The manifest link now has crossorigin="use-credentials", and the service worker's offline page treats a redirect as "the server is back" so it reloads too.

How you tested it

  • npx tsc --noEmit -p tsconfig.app.json and npm run build pass. The Python side is untouched.

  • Checked in headless Chromium that fetch(…, {redirect: 'manual'}) against a 302 to another origin returns type: "opaqueredirect", which is the signal the code uses.

  • Not tried on a real phone behind Access yet.

  • scripts/check.sh passes (only tsc run here, no venv in this environment)

  • User-visible change: entry added at the top of docs/changelog.json

  • New UI strings wrapped in t('…'): none added

  • Manual updated (MANUAL.md, Hosting → "Access on phones")

  • No secrets, chats or personal data in the diff

New dependencies

None.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WMaPdTydQ3WSCNyWbHRZeg


Generated by Claude Code

When the Access session runs out, every API call gets a cross-origin redirect
to Cloudflare's login, which fetch can't follow, so the app showed
"Can't reach Shell:B" forever. net.ts now checks /api/auth/me without
following redirects and reloads the page so Access can sign in. The manifest
link sends cookies so phones behind Access can install the app.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WMaPdTydQ3WSCNyWbHRZeg
@EveAeternam EveAeternam self-assigned this Oct 13, 2026
@EveAeternam
EveAeternam marked this pull request as ready for review October 13, 2026 02:20
@EveAeternam
EveAeternam merged commit a887dbc into main Oct 13, 2026
2 checks 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.

2 participants