{"record":{"id":"fa9edcb0d3b85f29","repo":"vercel/next.js","slug":"warning-total-number-of-custom-routes-exceeds-100","errorCode":null,"errorMessage":"Warning: total number of custom routes exceeds 1000, this can reduce performance. Route counts:\nheaders: ${headers.length}\nrewrites: ${totalRewrites}\nredirects: ${redirects.length}\nSee more info: https://nextjs.org/docs/messages/max-custom-routes-reached","messagePattern":"Warning: total number of custom routes exceeds 1000, this can reduce performance\\. Route counts:\nheaders: (.+?)\nrewrites: (.+?)\nredirects: (.+?)\nSee more info: https://nextjs\\.org/docs/messages/max-custom-routes-reached","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/lib/load-custom-routes.ts","lineNumber":722,"sourceCode":"  config: NextConfig\n): Promise<CustomRoutes> {\n  const [headers, rewrites, redirects] = await Promise.all([\n    loadHeaders(config),\n    loadRewrites(config),\n    loadRedirects(config),\n  ])\n\n  const onMatchHeaders: Header[] = []\n\n  const totalRewrites =\n    rewrites.beforeFiles.length +\n    rewrites.afterFiles.length +\n    rewrites.fallback.length\n\n  const totalRoutes = headers.length + redirects.length + totalRewrites\n\n  if (totalRoutes > 1000) {\n    console.warn(\n      bold(yellow(`Warning: `)) +\n        `total number of custom routes exceeds 1000, this can reduce performance. Route counts:\\n` +\n        `headers: ${headers.length}\\n` +\n        `rewrites: ${totalRewrites}\\n` +\n        `redirects: ${redirects.length}\\n` +\n        `See more info: https://nextjs.org/docs/messages/max-custom-routes-reached`\n    )\n  }\n\n  const cacheControlSources: string[] = []\n  for (const headerRoute of headers) {\n    if (!headerRoute.source.startsWith('/_next/')) {\n      continue\n    }\n    for (const header of headerRoute.headers) {\n      if (header.key.toLowerCase() === 'cache-control') {\n        cacheControlSources.push(headerRoute.source)\n        break","sourceCodeStart":704,"sourceCodeEnd":740,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/lib/load-custom-routes.ts#L704-L740","documentation":"Error \"Warning: total number of custom routes exceeds 1000, this can reduce performance. Route counts:\nheaders: ${headers.length}\nrewrites: ${totalRewrites}\nredirects: ${redirects.length}\nSee more info: https://nextjs.org/docs/messages/max-custom-routes-reached\" thrown in vercel/next.js.","triggerScenarios":"Thrown at packages/next/src/lib/load-custom-routes.ts:722 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the number of custom headers/rewrites/redirects below 1000, or consolidate them with dynamic patterns."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}