Matan Nahmani
Matan Nahmani8mo ago

calling TRPCProxyClient from inside trpc procedure fails on vercel route handlers edge runtime

i setup my client as following:
export const serverToServerApi = createTRPCProxyClient<AppRouter>({
transformer,
links: [
httpLink({
url: getUrl(),
fetch: async (input, init) => {
console.log("fetch", input, init);
const res = await fetch(input, init);
console.log("RES", res);
return fetch(input, init);
},
headers() {
return {
"x-trpc-source": "server",
Authorization: `Bearer ${env.SERVER_API_KEY}`,
};
},
}),
],
});
export const serverToServerApi = createTRPCProxyClient<AppRouter>({
transformer,
links: [
httpLink({
url: getUrl(),
fetch: async (input, init) => {
console.log("fetch", input, init);
const res = await fetch(input, init);
console.log("RES", res);
return fetch(input, init);
},
headers() {
return {
"x-trpc-source": "server",
Authorization: `Bearer ${env.SERVER_API_KEY}`,
};
},
}),
],
});
and then inside a trpc procedure i'm trying to call it as following:
void serverToServerApi.ai.newMembers.mutate({
roomId: room.id,
preferenceIds: [insertResult[0].id],
});
void serverToServerApi.ai.newMembers.mutate({
roomId: room.id,
preferenceIds: [insertResult[0].id],
});
this result in request always failing with an error of:
TRPCClientError: Unexpected end of JSON input
TRPCClientError: Unexpected end of JSON input
any ideas how to solve this?
0 Replies
No replies yetBe the first to reply to this messageJoin