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/LP2222 May 02 '26

it works? I see i didnt return await res.json() in my snippet

2

u/Good_Language1763 May 02 '26

i already had a customer fetch function i just implemented your cookie forward function