NeoBeanN
tRPC2y ago
1 reply
NeoBean

Client request headers with createTRPCProxyClient

Simple proxy client, following the documentation
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client'
import SuperJSON from 'superjson'
// .. other imports

export const trpcServer = createTRPCProxyClient<TRPCRootRouter>({
    transformer: SuperJSON,
    links: [httpBatchLink({ url: envs.API_URL_ABSOLUTE })],
})


I'm using this helper inside my sveltekit load function, which runs server side.
I see no way of forwarding the headers which i get from browser.
import { trpcServer } from 'lib/trpc.server'

export const load = (async ({ request: { headers } }) => {
    // no way to forward request.headers
    await trpcServer.user.me.query()
})
Was this page helpful?