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

848 B

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.

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.

export const config = {
  api: {
    responseLimit: '8mb',
  },
}