Closed SeanCassiere closed 3 weeks ago
The same happens to me when I'm trying to check authenticated user :(
export const Route = createFileRoute("/")({
beforeLoad: ({ context }) => {
console.log("/index > beforeLoad > context", context);
if (!context.auth.isAuthenticated) {
throw redirect({ to: "/login" });
} else {
throw redirect({ to: "/home" });
}
},
});
The redirect()
does nothing
I'm experiencing the same issue
Yeah same issue
Same!
Downgrading to 1.31.0
fixes it for meow.
Describe the bug
Redirects that are thrown after the client has been loader are not being resolved to their leaf node/route.
So, when you throw a redirect in the
beforeLoad
orloader
callback functions (after the client has loaded), its redirect isn't being followed through to the destination.There are differing behaviours shown based on where the
redirect
is thrown from.beforeLoad
callback, it stops at showing the defaultPendingComponent:loader
callback, the following console warning is logged out.This console warning has been attached to this issue.
Your Example Website or App
https://stackblitz.com/edit/github-kul4mf?file=src%2Froutes%2Findex.tsx
Steps to Reproduce the Bug or Issue
Expected behavior
As a user, I expect a redirect call that is thrown in either the
beforeLoad
orloader
callbacks, to resolve to the final leaf node/route. This should work, regardless of whether it is a "first-load" or if the user navigating to the page from a previous page within the app.Screenshots or Videos
full console warning message: qgniqpqvxgithub-qegz--3001--41fbae16.local-credentialless.txt
Platform
@tanstack/react-router
: 1.31.1Additional context
No response