Using tRPC to connect to two different apis

I have a create-t3-app where I am using tRPC for the api. It works great but I need to run a separate server for some long-running tasks (which won't fit on vercel) and I want to use trpc for that too. I created a separate createTRPCNext for it, and in _app.tsx I have:
return secondApi.withTRPC(api.withTRPC(MyApp));
return secondApi.withTRPC(api.withTRPC(MyApp));
The problem is that tRPC only looks at the inner context no matter which api I use in my code, and requests are sent to it. Is there a way to have the 2 contexts not get confused by tRPC?
3 Replies
Neto
Neto2y ago
you can use your first trpc provider as a proxy to the external service
Neto
Neto2y ago
᲼᲼᲼
᲼᲼᲼2y ago
You mean defining each route once in the next router and once in the other server router and making a request from one to the other? I don't like the code duplication and added latency
Want results from more Discord servers?
Add your server