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",
// ..
});
}
/_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",
// ..
});
}