Nitro and tRPC in vercel-edge
Hey there! I hope this is the right place to ask for help.
I am trying to deploy an application with Nitro and tRPC with the vercel-edge preset.
I am getting a weird proxy error when I deploy it without making any changes to how tRPC is handled.
I think I need to use the
They provide examples for Next.js, Remix, and SoldStart, but not Nuxt/Nitro.
Nitro uses
My initial, naive approach was to simply map back and forth between the two using these utilities I found for astro: https://github.com/withastro/astro/blob/2dca81bf2174cd5c27cb63cb0ae081ea2a1ac771/packages/integrations/vercel/src/serverless/request-transform.ts#L2
But again I am getting errors that seem to stem from Nitro using
If anyone has any pointers or if anyone has a repo of a Nuxt/Nitro project that uses tRPC on the edge that would be awesome!
Thanks already for your help!
I am trying to deploy an application with Nitro and tRPC with the vercel-edge preset.
I am getting a weird proxy error when I deploy it without making any changes to how tRPC is handled.
I think I need to use the
fetchRequestHanlder as described in the tRPC documentation for Fetch / Edge Runtimes https://trpc.io/docs/server/adapters/fetchThey provide examples for Next.js, Remix, and SoldStart, but not Nuxt/Nitro.
Nitro uses
IncommingMessage and ServerResponse, while the fetchRequestHandler expects a Request and returns a Response.My initial, naive approach was to simply map back and forth between the two using these utilities I found for astro: https://github.com/withastro/astro/blob/2dca81bf2174cd5c27cb63cb0ae081ea2a1ac771/packages/integrations/vercel/src/serverless/request-transform.ts#L2
But again I am getting errors that seem to stem from Nitro using
node-fetch under the hood? I am not experienced enough with the edge runtime or nitro to completely understand why it would not work and what needs to happen to make tRPC and Nitro on edge work together.If anyone has any pointers or if anyone has a repo of a Nuxt/Nitro project that uses tRPC on the edge that would be awesome!
Thanks already for your help!
You can create a tRPC server within any edge runtime that follow the WinterCG, specifically the Minimum Common Web Platform API specification.
GitHub
The all-in-one web framework designed for speed.
Star to support our work! - astro/request-transform.ts at 2dca81bf2174cd5c27cb63cb0ae081ea2a1ac771 · withastro/astro