Skip to content

fix(api-client): homepage no longer auto-redirects to /login#53

Merged
mastermanas805 merged 1 commit into
mainfrom
fix/w10-public-route-401-redirect-fresh
May 14, 2026
Merged

fix(api-client): homepage no longer auto-redirects to /login#53
mastermanas805 merged 1 commit into
mainfrom
fix/w10-public-route-401-redirect-fresh

Conversation

@mastermanas805
Copy link
Copy Markdown
Member

Summary

  • Root cause: src/api/index.ts 401-handler had an inverted skip-list — only /login and /claim were exempted from the auto-redirect. Any other public route (/, /pricing, /docs, /blog, /use-cases, /status, /incidents) could be bounced to /login if a stray api call from a hook / Suspense boundary / cached service worker returned 401.
  • Fix: invert the gate. Only redirect when path starts with /app. Public routes clear the stale token silently and throw the APIError to the caller without nav.
  • Adds a regression test pinning pathname stability on / when fetchMe returns 401.

Test plan

  • vitest: 92/95 pass (3 skipped, no regressions)
  • tsc --noEmit clean
  • After deploy: visit instanode.dev with stale localStorage token — confirm no redirect; visit instanode.dev/app/overview with no token — confirm redirect to /login

🤖 Generated with Claude Code

…epage redirect bug)

Root cause: src/api/index.ts had an inverted skip-list — only /login and
/claim were excluded from the 401→/login auto-redirect. Any other public
route (/, /pricing, /docs, /blog, /use-cases, /status, /incidents) could
get bounced to /login if a stray api call from a hook, Suspense boundary,
or cached service worker returned 401.

Fix: invert the gate. Redirect only when on /app/*. On public routes,
clear the stale token silently and throw the APIError to the caller
without navigating — the page stays renderable for an anonymous visitor.

+1 regression test pinning pathname stability on / when fetchMe returns
401. 92/95 api tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 merged commit 8c62867 into main May 14, 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.

1 participant