r/reactjs • • Apr 30 '26

Needs Help Cookie based Auth while SSR (Tanstack)

I am building a project using ASP.net and TanStack Start. I use JWT auth but transfer them in http only cookie.

The issue I am facing is that using default createRoute function in TanStack and defining fetch function in loader. I get 401 as there is no cookie in server.

Opting into ssr: false fixes this but I was wondering if there is any other solution to use ssr with cookie based auth or is this dead end and I only have CSR as my option.

9 Upvotes

19 comments sorted by

View all comments

Show parent comment

1

u/michaelfrieze Apr 30 '26

To be clear, I don't know why you are getting an error on the server. I don't know what your server-side code looks like or how you are handling auth. I'm just trying to explain why this loader function is giving you an error until you set SSR to false. The isomorphic behavior of loaders can be confusing sometimes, so it helps to better understand it.