Ryan Gillie
Ryan Gillie
TtRPC
Created by Ryan Gillie on 3/26/2025 in #❓-help
How to forward headers (cookies) w/ Tanstack Start
After playing around some more, I was able to simplify it to
const getIncomingHeaders = createIsomorphicFn()
.client(() => ({}))
.server(() => getHeaders());

// ...

const trpcClient = createTRPCClient<TRPCRouter>({
links: [
httpBatchStreamLink({
headers: getIncomingHeaders(),
transformer: superjson,
url: getUrl(),
}),
],
});
const getIncomingHeaders = createIsomorphicFn()
.client(() => ({}))
.server(() => getHeaders());

// ...

const trpcClient = createTRPCClient<TRPCRouter>({
links: [
httpBatchStreamLink({
headers: getIncomingHeaders(),
transformer: superjson,
url: getUrl(),
}),
],
});
4 replies