T
tRPC

how to access body in middleware

how to access body in middleware

TTaylorFay10/10/2023
Hi, I’m using trpc with nextjs. Does anyone know how to access the request’s body in middleware? As per the Request docs, the body can only be accessed once via await req.json(). However, if I do that in the middleware, the body is unusable within the trpc procedure.
Nnlucas10/10/2023
Why do you need the body? You can manipulate the web request directly, but using an input parser would be the more standard way of getting data from a request. Middlewares can access to the input too if needed

Looking for more? Join the community!

T
tRPC

how to access body in middleware

Join Server