NeoBeanN
tRPC3y ago
3 replies
NeoBean

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() }
}


I'm following the external routers. https://trpc.io/docs/client/nextjs/server-side-helpers#2-external-router
Was this page helpful?