dion
dion14mo ago

forwarding headers in solidjs

I have a setup with solidstart, and im trying to forward the client headeres to ttrpc. Here's my setup:
// This is not forwarding the client headers.
export const trpc = createTRPCProxyClient<IAppRouter>({
links: [
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
headers() {
// how to forward client headers?
const heads = new Map(); // <-- specifically this part
return Object.fromEntries(heads);
},
}),
],
});
// This is not forwarding the client headers.
export const trpc = createTRPCProxyClient<IAppRouter>({
links: [
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
headers() {
// how to forward client headers?
const heads = new Map(); // <-- specifically this part
return Object.fromEntries(heads);
},
}),
],
});
This is how i'm calling the trpc client from my component:
export const routeData = () => {
return createServerData$(async () => {
const organizations =
await trpc.organization.getOrganizationsByUser.query();
return organizations;
});
};

const Page: VoidComponent = () => {
const organizations = useRouteData<typeof routeData>();
return (
<div>
Organizations
</div>
);
};

export default Page;
export const routeData = () => {
return createServerData$(async () => {
const organizations =
await trpc.organization.getOrganizationsByUser.query();
return organizations;
});
};

const Page: VoidComponent = () => {
const organizations = useRouteData<typeof routeData>();
return (
<div>
Organizations
</div>
);
};

export default Page;
Is there a way to forward the headers received by the handler?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?