Ali Samadi
Ali Samadi2mo ago

authenticatedProcedure

Is it true that for every requests, it is going to call getSession()? If yes, what is a good workaround or this is how everyone is doing?
No description
4 Replies
Nick
Nick2mo ago
Yes middlewares run on every request, and it's necessary to validate sessions on every request, but the strength of using JWTs would be you can validate them without needing to make a DB or API call. If this is better-auth then presumably you're just making a DB query though and that's likely to be fine
Ali Samadi
Ali SamadiOP2mo ago
Thanks for the help Nick!
RodeoSprite
RodeoSprite3w ago
I was working on a nextjs monorepo using trpc as backend I am integrating SSE with normal trpc methods, I implemented auth using better auth and it works very smoothly, but when I try to prefetch on server components I get not authenticated user error, but after render the app works without error. I checked further and reached upon conclusion that cookies aren't resolved because when I tried passing headers vis prop drilling from TRPC provider and using those in getting auth it worked and prefetching worked. Here is my problem, any help would be appreciated https://stackoverflow.com/questions/79823260/trpc-prefetching-fails-on-protected-procedure
Stack Overflow
TRPC prefetching fails on protected procedure
I was working on a nextjs monorepo using trpc as backend I am integrating SSE with normal trpc methods, I implemented auth using better auth and it works very smoothly, but when I try to prefetch on
Nick
Nick3w ago
@RodeoSprite that sounds like a different question so I would suggest you start a new one. But nextjs will indeed need a different mechanism on the client vs server for fetching the cookies and also likely on the first load - I am not a nextjs user so afraid I can't help in any depth, but chatgpt etc should be able to help

Did you find this page helpful?