Skip to content

Body Limit Plugin

Body Limit Plugin helps restrict the size of the request body.

Import

Depending on your adapter, import the corresponding plugin:

ts
import { BodyLimitHandlerPlugin } from '@orpc/server/fetch'
import { BodyLimitHandlerPlugin } from '@orpc/server/node'

Setup

Set maxBodySize to the maximum number of bytes allowed:

ts
const handler = new RPCHandler(router, {
  plugins: [
    new BodyLimitHandlerPlugin({
      maxBodySize: 1024 * 1024, // 1MB
    }),
  ],
})

INFO

The handler can be any supported oRPC handler, such as RPCHandler, OpenAPIHandler, or a custom one.

Learn More

For implementation details, see the fetch adapter source code and the node adapter source code.

Released under the MIT License.