vercel/next.js · error

API response for ${req.url} exceeds ${bytes.format(maxConten

Error message

API response for ${req.url} exceeds ${bytes.format(maxContentLength)}. API Routes are meant to respond quickly. https://nextjs.org/docs/messages/api-routes-response-size-limit

What it means

Error "API response for ${req.url} exceeds ${bytes.format(maxContentLength)}. API Routes are meant to respond quickly. https://nextjs.org/docs/messages/api-routes-response-size-limit" thrown in vercel/next.js.

Source

Thrown at packages/next/src/server/api-utils/node/api-resolver.ts:401

          : '1mb'
      )
    }

    let contentLength = 0
    const maxContentLength = getMaxContentLength(responseLimit)
    const writeData = apiRes.write
    const endResponse = apiRes.end
    apiRes.write = (...args: any[2]) => {
      contentLength += Buffer.byteLength(args[0] || '')
      return writeData.apply(apiRes, args)
    }
    apiRes.end = (...args: any[2]) => {
      if (args.length && typeof args[0] !== 'function') {
        contentLength += Buffer.byteLength(args[0] || '')
      }

      if (responseLimit && contentLength >= maxContentLength) {
        console.warn(
          `API response for ${req.url} exceeds ${bytes.format(
            maxContentLength
          )}. API Routes are meant to respond quickly. https://nextjs.org/docs/messages/api-routes-response-size-limit`
        )
      }

      return endResponse.apply(apiRes, args)
    }
    apiRes.status = (statusCode) => sendStatusCode(apiRes, statusCode)
    apiRes.send = (data) => sendData(apiReq, apiRes, data)
    apiRes.json = (data) => sendJson(apiRes, data)
    apiRes.redirect = (statusOrUrl: number | string, url?: string) =>
      redirect(apiRes, statusOrUrl, url)
    apiRes.setDraftMode = (options = { enable: true }) =>
      setDraftMode(apiRes, Object.assign({}, apiContext, options))
    apiRes.setPreviewData = (data, options = {}) =>
      setPreviewData(apiRes, data, Object.assign({}, apiContext, options))
    apiRes.clearPreviewData = (options = {}) =>

View on GitHub (pinned to 0eb3775416)

Solutions

  1. Reduce the API response size below the limit, or raise `api.responseLimit` in next.config.
  2. Stream or paginate large responses instead of returning them in one body.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/next/src/server/api-utils/node/api-resolver.ts:401 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/1768ac3d9525c0c0. Report an issue: GitHub.