Klo
Klo
TTCTheo's Typesafe Cult
Created by Klo on 11/18/2023 in #questions
Questions about trpc interactions with cookies/headers
Hey there ! I'm currently migrating a t3 app to the app router, and I have some questions about the trpc implementation. 1. In the trpc client provider (https://github.com/t3-oss/create-t3-app/blob/cef18c6e6e96ff0b4adffbe8d99a5960d6770a83/cli/template/extras/src/trpc/react.tsx), cookies props are passed from the global layout, but i don't see how it's useful seeing as browser requests always send cookies anyway, so what's the point of using them here ? 2. When using trpc in a rsc, an http request is made from the server to itself. It caused issues on my end as it triggers my next.js middleware, where clerk would block the request as it was missing information from the original client request. I think it also adds some (maybe a lot ?) of overhead. Wouldn't it make more sense to instead create a server caller (https://trpc.io/docs/server/server-side-calls) ? I can see some painpoints when creating the trpc context for the caller (the entire request object isn't accessible on a rsc), but the cookies and headers functions could be used to create the trpc context
2 replies