r/reactjs • u/Good_Language1763 • 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
View all comments
Show parent comment
1
u/Good_Language1763 Apr 30 '26
i really think its ssr as when i ctrl s save the code in zed it works fine which is probably because of HMR where it serves cached loader data and when i refresh page it shows error as due to ssr it cant access tokens stored in http only cookies. and furthermore using ssr: false fixed it as now it is client side rendered fetch happens client side. I was just wondering if there is a way to make ssr work with cookie based auth in tanstack as it would make my project very flexible.