Skip to content

fix: force full-document navigation on auth-route redirects - #14

Open
nandan-bhat wants to merge 1 commit into
mainfrom
fix/SDK-10669-reload-document
Open

fix: force full-document navigation on auth-route redirects#14
nandan-bhat wants to merge 1 commit into
mainfrom
fix/SDK-10669-reload-document

Conversation

@nandan-bhat

@nandan-bhat nandan-bhat commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

The SDK route guards and redirect helpers send users to /auth/* routes like /auth/login and /auth/logout. These routes are served by the auth0Middleware at the HTTP layer. They are not registered in the TanStack Router route tree.

Because of this, a client-side navigation (through <Link>, router.navigate(), or a beforeLoad that runs without a full page load) made the router try to match /auth/login inside its own route tree. That match failed and the router returned Not Found (404).

This happened because TanStack Router only auto-enables reloadDocument for absolute URLs. Our redirects use relative paths like /auth/login, so the flag stayed off and the router handled them internally instead of letting the browser reach the server.

The fix sets reloadDocument: true on every SDK redirect that targets an auth route. This forces a real browser navigation so the request reaches auth0Middleware. Full page loads and SSR were never affected, because the server handles the redirect before the router runs.

Changes

  • Set reloadDocument: true on all 7 redirect sites:
    • requireAuth and requireOrg in src/client/guards.ts
    • login and logout in src/client/imperative.ts
    • requireAuthMiddleware and requireOrgMiddleware in src/server/middleware.ts
  • Added tests that assert each redirect carries reloadDocument: true.

Testing

  • Build, lint, and the full test suite pass.

The /auth/* routes are served by HTTP middleware, not registered in the
TanStack Router tree. On a client-side navigation the router tried to match
the relative redirect target internally and returned Not Found. Adding
reloadDocument: true makes the router hand these redirects to the server.
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