dion
dion
TtRPC
Created by dion on 11/2/2023 in #❓-help
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?
1 replies