vercel/next.js · error

Warning: total number of custom routes exceeds 1000, this ca

Error message

Warning: total number of custom routes exceeds 1000, this can reduce performance. Route counts:
headers: ${headers.length}
rewrites: ${totalRewrites}
redirects: ${redirects.length}
See more info: https://nextjs.org/docs/messages/max-custom-routes-reached

What it means

Error "Warning: total number of custom routes exceeds 1000, this can reduce performance. Route counts: headers: ${headers.length} rewrites: ${totalRewrites} redirects: ${redirects.length} See more info: https://nextjs.org/docs/messages/max-custom-routes-reached" thrown in vercel/next.js.

Source

Thrown at packages/next/src/lib/load-custom-routes.ts:722

  config: NextConfig
): Promise<CustomRoutes> {
  const [headers, rewrites, redirects] = await Promise.all([
    loadHeaders(config),
    loadRewrites(config),
    loadRedirects(config),
  ])

  const onMatchHeaders: Header[] = []

  const totalRewrites =
    rewrites.beforeFiles.length +
    rewrites.afterFiles.length +
    rewrites.fallback.length

  const totalRoutes = headers.length + redirects.length + totalRewrites

  if (totalRoutes > 1000) {
    console.warn(
      bold(yellow(`Warning: `)) +
        `total number of custom routes exceeds 1000, this can reduce performance. Route counts:\n` +
        `headers: ${headers.length}\n` +
        `rewrites: ${totalRewrites}\n` +
        `redirects: ${redirects.length}\n` +
        `See more info: https://nextjs.org/docs/messages/max-custom-routes-reached`
    )
  }

  const cacheControlSources: string[] = []
  for (const headerRoute of headers) {
    if (!headerRoute.source.startsWith('/_next/')) {
      continue
    }
    for (const header of headerRoute.headers) {
      if (header.key.toLowerCase() === 'cache-control') {
        cacheControlSources.push(headerRoute.source)
        break

View on GitHub (pinned to 0eb3775416)

Solutions

  1. Reduce the number of custom headers/rewrites/redirects below 1000, or consolidate them with dynamic patterns.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/next/src/lib/load-custom-routes.ts:722 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/fa9edcb0d3b85f29. Report an issue: GitHub.