ian
ian
TtRPC
Created by ian on 12/8/2023 in #❓-help
How to pass through authentication header when using createTRPCProxyClient and RSC?
You may need to call your procedure(s) directly from the same server they're hosted in
So - this would generally be the right solution, but our trpc server is not within the nextjs trpc webapp. We have multiple diff nextjs servers all proxying calls (via next.config.js rewrites) from web -> API server. So the flow sorta looks like this: browser =[auth cookie]=> vercel RSC (server action) =[proxy auth header]=> tRPC fastify server Really what I'm trying to figure out is how to add the auth header at the RSC step.
9 replies
TtRPC
Created by ian on 12/8/2023 in #❓-help
How to pass through authentication header when using createTRPCProxyClient and RSC?
Sorry, I must have not been clear. This is for React Server Components, where the rendering occurs 100% on server. So the client implementation doesn't get touched, this is exclusively on the server side. We're currently using the proxy implementation, not the SSR implementation, but I'm unclear how to go from RSC context (req,res) and apply that req.headers.authorization to the proxy client, which is initialized elsewhere. It would be cumbersome to require each RSC component to pass an auth header, but I'm failing to see any other options here.
9 replies