TanStackT
TanStack6d ago
2 replies
verbal-lime

Context missing on hmr

When I make a change to a route, save it, for some reason the session user is undefined making me get redirected to login every time I make a change.

Seems like it might be an issue with createRootRouteWithContext not running beforeLoad and therefore doesn't populate the session(Im using better auth)

__root.tsx
beforeLoad: async () => {
const session = await getSessionFn()

return { session }
},

In the image you can see logs that I set up, when I make a change to a route, the sessions.user is undefined, this causes a redirect to /login, but on the /login, session.user IS defined meaning i get redirected to /user, am I doing something wrong, I just noticed this issue this morning and it didn't happen before and I did not make changes to the auth sessions sytem. I'm running "@tanstack/react-start": "^1.145.10", "@tanstack/react-router": "^1.132.0",
image.png
Was this page helpful?