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 beforeLoadruns 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.


2 Replies
deep-jadeOP•16mo ago
These are my console logs coming from sign-in when I hit refresh if I add a console log there.


deep-jadeOP•16mo ago
I have solved it by following the authentication example.