Skip to content

Latest commit

 

History

History
49 lines (31 loc) · 1.4 KB

File metadata and controls

49 lines (31 loc) · 1.4 KB

elections-cpl.api.hscc.bdpa.orgDocs


elections-cpl.api.hscc.bdpa.org / lib/next-adhesive/add-raw-body / default

Function: default()

default(req, res, context): Promise<void>

Adds a rawBody property onto the NextApiRequest object, which contains the raw unparsed content of the request body if it exists or undefined if it does not. The body is still parsed (using bodyParser) like normal using a custom implementation of Next.js's parseBody function.

To use this middleware, bodyParser must be disabled via Next.js API route configuration like so:

export const config = {
  api: {
    bodyParser: false
  },
}

Note that this middleware cannot be used with other middleware or routes that also directly consume the request body in a special way, such as when using streams.

Parameters

req: NextApiRequest

res: NextApiResponse

context: MiddlewareContext<Options>

Returns

Promise<void>

See

https://nextjs.org/docs/api-routes/api-middlewares#custom-config

Source

lib/next-adhesive/add-raw-body.ts:100