tRPC does not have headers data when refreshing.
I'm using tanstack-start, tRPC and better-auth in my project and have it setup like this
I'm currently running into a problem where navigating normally in the app, I get the data that I need from tRPC. However, when reloading by
CTRL+R
I get UNAUTHORIZED
since I'm using a protected procedure whichj looks like this:
So I investigated a little and have found that opts.req.headers
just doesn't have the headers that I need. However, here's where I dont get it, the headers do absolutely exist.
I verified this by creating a server function
and using it on the loader like this before my trpc request
But when I do console.log(opts.req.headers)
inside createContext it does not exist.2 Replies