Repository navigation
Phones: sign in again when Cloudflare Access expires instead of hanging - #5
Merged
Merged
Conversation
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
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.
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.tsasks/api/auth/mewithout following redirects. If the answer is a redirect (or a 401/403, which Shell:B's own/api/auth/menever 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 hascrossorigin="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.jsonandnpm run buildpass. The Python side is untouched.Checked in headless Chromium that
fetch(…, {redirect: 'manual'})against a 302 to another origin returnstype: "opaqueredirect", which is the signal the code uses.Not tried on a real phone behind Access yet.
scripts/check.shpasses (only tsc run here, no venv in this environment)User-visible change: entry added at the top of
docs/changelog.jsonNew UI strings wrapped in
t('…'): none addedManual 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