Help Retrieving req.url from opts in useMutation from tRPC
Hello, i'm trying to essentially send a magiclink email using supabase client libraries, however, i'm running into an issue of not being able to retrieve the req.url (in order to get the baseURL). I would prefer not to hard-code it due to changing addresses between localhost, Vercel Preview Branches, Primary Domain.
Code Context
I believe the way to go here is to utilize a context, however, i'm having trouble setting that up throughout the react-query client portion alongside with the server portion.
My current repo is 1:1 to jherr's nextjs App Router setup, except it has this auth router composing into the primary appRouter.
https://github.com/jherr/trpc-on-the-app-router/tree/main/src/app
I'm confused on how to override the fetchRouterHandler on the client side to properly pass through the req / res object.
Attempt at making the context
GitHub
trpc-on-the-app-router/src/app at main · jherr/trpc-on-the-app-router
Code for the tRPC on the App Router video. Contribute to jherr/trpc-on-the-app-router development by creating an account on GitHub.
Solution:Jump to solution
I just figured it out, it was my lack of understanding that the fetchRouterHandler was meant for edge runtimes, and I had to change my createContext function to
FetchCreateContextFnOptions
change my trpc route handler appropriatly for the fetchRouter: /app/api/trpc/[trpc]/route.ts
```ts
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import { appRouter } from "@/api-server";...1 Reply
Solution
I just figured it out, it was my lack of understanding that the fetchRouterHandler was meant for edge runtimes, and I had to change my createContext function to
FetchCreateContextFnOptions
change my trpc route handler appropriatly for the fetchRouter: /app/api/trpc/[trpc]/route.ts