Cookie based auth review.
Hi all!
I just wanted to confirm if my "solution" works fines, break no rules etc. as it's really important for me. I don't want to make mistake that will cost me a lot in the future. If anyone like, please tell me if my approach is legit, alternatively leave your suggestions please! I'll be grateful.
main.tsx:
routes/login/index.tsx:
1 Reply
correct-apricotOP•7mo ago
below protected route: routes/ _authenticated.tsx
also last file under 'protected group": routes/ _authenticated/dashboard/index.tsx:
I'm curious about few things:
- is validating by source of truth as a tanstack-query("user" query) is fine? And my approach in
beforeLoad
is okay?
- am I doing right by setting query to null and invalidate it on logout action?
- Also, I don't like:
it's because .then throw redirect so it passed to nearest catch block.. is there any other way to do this? 😄