T
TanStack9mo ago
other-emerald

Invariant Failed: _authed to _non-authed Route

I'm running into issues with logging out and redirecting to a non-authorized route. I set my routes up as follows: /_authed/dashboard /_non-authed/login /_non-authed/register When I try to handle logout, I receive the following error: @tanstack_react-router.js?v=a4848d55:828 Uncaught Error: Invariant failed: Could not find an active match from "/_authed" On refresh of the page, login is rendered. I have confirmed logout funciton is working properly and session storage is cleared. I have tried with/without invalidate/navigate with the same result. const handleLogout = async () => { await logout(); router.invalidate(); navigate({ to: "/login" }); }; _authed (_non-authed does the inverse with redirect to /dashboard): beforeLoad: async ({ context, location }) => { if (!context.session) { throw redirect({ to: "/login", // .. }); }
5 Replies
fascinating-indigo
fascinating-indigo9mo ago
This might be a similar issue to the one we were just talking about in #router , starting from this message https://discord.com/channels/719702312431386674/1007702008448426065/1325198997140541553
other-emerald
other-emeraldOP9mo ago
Oh, thanks, I missed that. I dug into it but couldn't find any relevent solutions. I tried adding a timeout without success and doesn't appear to be version related (running 1.92.3 - https://github.com/TanStack/router/issues/1353#issuecomment-2555173727)
GitHub
HMR crash (under very specific circumstances) · Issue #1353 · TanSt...
Describe the bug I've got a real interesting HMR bug. It only happens under very specific circumstances. This is the error message Invariant failed: No match found for route '/_layout/a/b&#...
fascinating-indigo
fascinating-indigo9mo ago
It seems this error can arise when using the wrong from argument in a hook (for example useMatch({ from: '/foo' }) when we're not on the /foo route). And we find that useLocation or useRouterState can sometimes indicate a pathname that does not match the currently rendered branch. Are you using some of those?
other-emerald
other-emeraldOP8mo ago
No, not using any of those, just navigate and redirect in this situation Any other ideas?
yelping-magenta
yelping-magenta8mo ago
please provide a complete minimal example by forking one of the existing examples on Stackblitz

Did you find this page helpful?