{"record":{"id":"b80f276fe7e673c3","repo":"sveltejs/kit","slug":"routes-include-must-contain-100-or-fewer-routes","errorCode":null,"errorMessage":"routes.include must contain 100 or fewer routes","messagePattern":"routes\\.include must contain 100 or fewer routes","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-cloudflare/utils.js","lineNumber":103,"sourceCode":" * @param {string[]} client_assets\n * @param {string[]} redirects\n * @param {import('./index.js').AdapterOptions['routes']} routes\n * @returns {import('./index.js').RoutesJSONSpec}\n */\nexport function get_routes_json(builder, client_assets, redirects, routes) {\n\tconst include = routes?.include ?? ['/*'];\n\tlet exclude = routes?.exclude ?? ['<all>'];\n\n\tif (!Array.isArray(include) || !Array.isArray(exclude)) {\n\t\tthrow new Error('routes.include and routes.exclude must be arrays');\n\t}\n\n\tif (include?.length === 0) {\n\t\tthrow new Error('routes.include must contain at least one route');\n\t}\n\n\tif (include?.length > 100) {\n\t\tthrow new Error('routes.include must contain 100 or fewer routes');\n\t}\n\n\t/** @type {Set<string>} */\n\tconst transformed_rules = new Set();\n\tfor (const rule of exclude) {\n\t\tif (rule === '<all>') {\n\t\t\ttransformed_rules.add('<build>');\n\t\t\ttransformed_rules.add('<files>');\n\t\t\ttransformed_rules.add('<prerendered>');\n\t\t\ttransformed_rules.add('<redirects>');\n\t\t} else {\n\t\t\ttransformed_rules.add(rule);\n\t\t}\n\t}\n\n\t/** @type {Set<string>} */\n\tconst excluded_routes = new Set();\n\tfor (const rule of transformed_rules) {","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/adapter-cloudflare/utils.js#L85-L121","documentation":"Cloudflare Pages limits _routes.json to at most 100 include rules. The adapter enforces this limit at build time, throwing when routes.include has more than 100 patterns, because the deploy would be rejected by Cloudflare.","triggerScenarios":"Passing routes.include with more than 100 pattern strings to adapter-cloudflare in svelte.config.js, e.g. a programmatically generated list of 150 route patterns.","commonSituations":"Large apps auto-generating an include rule per dynamic route; teams mirroring an old catch-all-plus-exceptions setup that grew over 100 entries.","solutions":["Consolidate patterns with wildcards, e.g. replace many /api/x rules with '/api/*'","Invert the logic: use a broad include like ['/*'] and move excess entries into exclude","Prerender pages that don't need the server function so they can be excluded with fewer rules"],"exampleFix":"// before\nadapter({ routes: { include: ['/a','/b','/c', /* ...150 rules */] } })\n// after\nadapter({ routes: { include: ['/a/*','/b/*'], exclude: ['<all>'] } })","handlingStrategy":"validation","validationCode":"const include = routes?.include ?? ['/*'];\nif (Array.isArray(include) && include.length > 100) {\n  throw new RangeError(`routes.include has ${include.length} rules; Cloudflare allows at most 100`);\n}","typeGuard":"const withinLimit = (r) => (r?.include ?? ['/*']).length <= 100;","tryCatchPattern":"try {\n  await vite.build();\n} catch (e) {\n  if (e.message.includes('100 or fewer routes')) {\n    console.error('Consolidate routes.include patterns using wildcards');\n  }\n  throw e;\n}","preventionTips":["Check include length in CI before deploying to Cloudflare Pages","Prefer wildcard patterns like '/api/*' over one rule per path","Keep the include list broad and push exceptions into exclude"],"tags":["config","limits","cloudflare"],"backgroundTag":"route-rules-limit-exceeded","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}