Skip to content

fix(cli-auth): provision /cli-auth route (was 404 on instanode.dev)#129

Merged
mastermanas805 merged 1 commit into
mainfrom
fix/cli-auth-route
May 21, 2026
Merged

fix(cli-auth): provision /cli-auth route (was 404 on instanode.dev)#129
mastermanas805 merged 1 commit into
mainfrom
fix/cli-auth-route

Conversation

@mastermanas805
Copy link
Copy Markdown
Member

Summary

  • User reported https://instanode.dev/cli-auth returns "That page is not provisioned." The api emits the canonical /login?cli_session=<id> since commit 0c7991c (B13-P0-F1, 2026-05-20), but /cli-auth still surfaces in cli/cmd/testapi_test.go (hermetic test mock) and in any stale terminal scrollback / chat transcript a user pastes.
  • Without a route, /cli-auth fell through to the catch-all NotFoundPage → 404.
  • Defensive redirect route now normalizes /cli-auth?cli_session=<id> and /cli-auth?s=<id> (test-mock shape) to canonical /login?cli_session=<id>. Bare /cli-auth redirects to /login.

Why this fix

  • The api code (api/internal/handlers/cli_auth.go) has always emitted /login?cli_session=<id> — confirmed by git log --all -p of that file. So the broken /cli-auth URL is NOT being emitted by the api today.
  • Most likely source per investigation: an older agent/CLI version OR a leaked test-mock URL. The CLI binary itself just opens whatever the api returns as auth_url, so a redirect on instanode.dev is the right defensive fallback regardless of where the stale URL came from.
  • Does NOT change or break the working /login?cli_session=... flow that the api currently emits.

What changed

  • src/App.tsx — new CliAuthRedirect component + route registration
  • scripts/prerender.mjs/cli-auth added to authShellRoutes (so dist/cli-auth/index.html is written; GH Pages must serve a real file for the SPA shell to boot the redirect) + ROUTE_META['/cli-auth'] entry for a sensible <title> during the brief redirect window
  • src/App.cli-auth.test.tsx — 5 unit tests pinning the contract

Test plan

  • npx tsc --noEmit — clean
  • npx vitest run — 769 passed, 3 skipped, 0 failed (full suite)
  • npm run build — prerender wrote 4 auth SPA shells (was 3); dist/cli-auth/index.html exists, title "Signing in CLI… · instanode"
  • New src/App.cli-auth.test.tsx: 5 tests pass
    • preserves ?cli_session=<id>/login?cli_session=<id>
    • rewrites ?s=<id> (test-mock shape) → /login?cli_session=<id>
    • bare /cli-auth/login (no param)
    • URL-encodes reserved characters in session ids
    • cli_session wins over s when both present
  • Post-merge: verify curl -I https://instanode.dev/cli-auth?cli_session=test returns 200 (SPA shell), and browser-loading the URL redirects to /login?cli_session=test

🤖 Generated with Claude Code

User reported "That page is not provisioned" when CLI device-flow
emitted `https://instanode.dev/cli-auth?cli_session=…`. The route
wasn't defined on the marketing site — it had to be either on the
dashboard OR a redirect from instanode.dev to the dashboard.

Fix: defensive redirect route `/cli-auth` → `/login?cli_session=<id>`.

Details:
- The api currently emits the canonical `/login?cli_session=<id>`
  path (cli_auth.go since commit 0c7991c, B13-P0-F1 2026-05-20).
- `/cli-auth` was never a real route — but it appears in
  `cli/cmd/testapi_test.go` (the hermetic test mock writes
  `https://instanode.dev/cli-auth?s=test`) and in any stale
  terminal scrollback / chat transcript a user pastes.
- Without a route, `/cli-auth` fell through to the catch-all
  NotFoundPage → 404.

Implementation:
- New `CliAuthRedirect` component in App.tsx normalizes both query
  shapes: `?cli_session=<id>` and `?s=<id>` (test-mock shape) →
  canonical `/login?cli_session=<id>`. Bare `/cli-auth` → `/login`.
- Route registered in App.tsx alongside the legacy /resources,
  /vault, /team, /billing redirects.
- `scripts/prerender.mjs` adds `/cli-auth` to authShellRoutes so
  `dist/cli-auth/index.html` is written at build time — otherwise
  GH Pages would 404 before the SPA shell could boot the Navigate.
- `ROUTE_META['/cli-auth']` adds a sensible <title> for the brief
  moment before the redirect runs.
- 5 unit tests in `src/App.cli-auth.test.tsx` lock in the contract:
  param preservation, ?s→cli_session rewrite, bare-fallback, URL
  encoding of reserved characters, cli_session-wins-over-s when
  both are present.

Does NOT touch the working `/login?cli_session=...` flow that the
api emits — that path remains canonical. This is purely a defensive
redirect for the legacy URL shape.

Verification:
- `npx tsc --noEmit`: clean
- `npx vitest run`: 769 passed, 3 skipped, 0 failed (full suite)
- `npm run build`: SSR prerender wrote 4 auth SPA shells (was 3);
  `dist/cli-auth/index.html` exists with title "Signing in CLI… · instanode"

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

size-limit report 📦

Path Size
dist/assets/index-Dg6gJ5Oz.js 0 B (-100% 🔽)
dist/assets/index-C9T0ot61.css 6.19 KB (0%)
dist/assets/index-BwyF-Dau.js 143.87 KB (+100% 🔺)

@mastermanas805 mastermanas805 merged commit 6d05222 into main May 21, 2026
13 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