fix: force full-document navigation on auth-route redirects - #14
Open
nandan-bhat wants to merge 1 commit into
Open
fix: force full-document navigation on auth-route redirects#14nandan-bhat wants to merge 1 commit into
nandan-bhat wants to merge 1 commit into
Conversation
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.
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.
Summary
The SDK route guards and redirect helpers send users to
/auth/*routes like/auth/loginand/auth/logout. These routes are served by theauth0Middlewareat theHTTP layer. They arenot registeredin the TanStack Routerroute tree.Because of this, a
client-side navigation(through<Link>,router.navigate(), or abeforeLoadthat runs without a full page load) made the router try tomatch/auth/logininside its own route tree. That matchfailedand the router returnedNot Found(404).This happened because TanStack Router only auto-enables
reloadDocumentforabsolute URLs. Our redirects userelative pathslike/auth/login, so the flag stayedoffand the router handled theminternallyinstead of letting the browser reach the server.The fix sets
reloadDocument: trueon every SDK redirect that targets an auth route. This forces areal browser navigationso the request reachesauth0Middleware.Full page loadsandSSRwere never affected, because the server handles the redirectbeforethe router runs.Changes
reloadDocument: trueon all7redirect sites:requireAuthandrequireOrginsrc/client/guards.tsloginandlogoutinsrc/client/imperative.tsrequireAuthMiddlewareandrequireOrgMiddlewareinsrc/server/middleware.tsreloadDocument: true.Testing
Build,lint, and thefull test suitepass.