rsnext/errors/api-routes-response-size-limit.md
Lee Robinson c480726da2
Update 4MB API Routes warning error guide. (#37779)
We added documentation for this, but didn't post it back to the error guide, which is linked when you'd hit this limit.

https://github.com/vercel/next.js/pull/34700
2022-06-16 21:59:54 +00:00

28 lines
848 B
Markdown

# API Routes Response Size Limited to 4MB
#### Why This Error Occurred
API Routes are meant to respond quickly and are not intended to support responding with large amounts of data. The maximum size of responses is 4MB.
#### Possible Ways to Fix It
If you are not using Next.js in a serverless environment, and understand the performance implications of not using a CDN or dedicated media host, you can set this limit to `false` inside your API Route.
```js
export const config = {
api: {
responseLimit: false,
},
}
```
`responseLimit` can also take the number of bytes or any string format supported by `bytes`, for example `1000`, `'500kb'` or `'3mb'`.
This value will be the maximum response size before a warning is displayed. The default value is 4MB.
```js
export const config = {
api: {
responseLimit: '8mb',
},
}
```