Where to find implementation of bodyParser middleware for next js api route
Hi trying to manually import the next js bodyParser middleware but cant find it's implementation in the next github repo, anybody know where I can find it ty : D
(Doing it to create a middleware for a trpc openapi router so can have the raw body for some endpoints and the parsed body for others)
2 Replies
I don't know if it helps or if it's true, but I found a library called parse-json which I think NextJS uses under the hood to parse requests. You can find it in node_modules
or check out /node_modules/next/dist/server/api-utils/node.js
ty so much seems to be this function in the utils file : D
https://github.com/vercel/next.js/blob/canary/packages/next/src/server/api-utils/node.ts#L145
GitHub
next.js/node.ts at canary · vercel/next.js
The React Framework. Contribute to vercel/next.js development by creating an account on GitHub.