tRPC does not have headers data when refreshing.
I'm using 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.5 Replies
conscious-sapphireOP•4mo ago
webRequest Log from server function looks like this

conscious-sapphireOP•4mo ago
log from trpc context looks like this

rare-sapphire•4mo ago
hey
flat-fuchsia•4mo ago
I solved it by adding headers in router.tsx https://github.com/makyinmars/tan-stack-start-full-stack/blob/main/app/router.tsx
GitHub
tan-stack-start-full-stack/app/router.tsx at main · makyinmars/tan...
Contribute to makyinmars/tan-stack-start-full-stack development by creating an account on GitHub.
rare-sapphire•4mo ago
As I understood this createIsomorphicFn do the black magic ? OD you have some docs about that ?