NeoBean
NeoBean11mo ago

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 })],
})
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()
})
import { trpcServer } from 'lib/trpc.server'

export const load = (async ({ request: { headers } }) => {
// no way to forward request.headers
await trpcServer.user.me.query()
})
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?