T
tRPC

Pass headers when prefetching using helpers

Pass headers when prefetching using helpers

NNeoBean11/20/2023
I dont see a way to pass headers and cookies with either fetch/prefetch methods from the ssr helper. They accept a context option but it is typed as a Record<string.., so i'm not sure what it does.
export const getServerSideProps = async ( ) => {
await ssHelpers.treedata.getAll.fetch(undefined)
await ssHelpers.treedata.getAll.prefetch(undefined)

return { trpcState: ssHelpers.dehydrate() }
}
export const getServerSideProps = async ( ) => {
await ssHelpers.treedata.getAll.fetch(undefined)
await ssHelpers.treedata.getAll.prefetch(undefined)

return { trpcState: ssHelpers.dehydrate() }
}
I'm following the external routers. https://trpc.io/docs/client/nextjs/server-side-helpers#2-external-router bump ?
Nnlucas11/20/2023
headers are sent from your Link on the client. I don't really use the Next/SSR stuff so some things may vary from my experience, but look at the links docs This isn't a web framework, so using cookies is unergonomic and way off the recommended track

Looking for more? Join the community!

T
tRPC

Pass headers when prefetching using helpers

Join Server