NeoBean
NeoBean13mo ago

Pass headers when prefetching using helpers

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
2 Replies
NeoBean
NeoBeanOP13mo ago
bump ?
Nick
Nick13mo ago
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