TanStackT
TanStack2y ago
2 replies
uniform-turquoise

On refresh, always getting redirected to home page.

I sort of understand why this is happening but not sure how to fix it.

In the first screenshot is my sign-in component. It basically says if there is a user and we are trying to access
/sign-in
, redirect to home page.

And the 2nd screenshot is my
__root.tsx
component where as soon as my auth is done, I call router.invalidate(). This makes sure that
beforeLoad
runs again.

The problem with this is my _public/sign-in route runs again and this time it goes inside the if statement and redirects to
/
.

So if I m let's say at /borrowings and I hit refresh, I get redirected to
/
. I m sure I m missing something here I just cannot find what it is.

Last screenshot is my current file/folder structure.

Any help appreciated.
Capture-2024-08-12_at_10.11.16.png
Capture-2024-08-12_at_10.24.55.png
Capture-2024-08-12_at_10.30.34.png
Was this page helpful?