{"record":{"id":"57edeae6082bc947","repo":"withastro/astro","slug":"error-generating-redirects-error-message","errorCode":null,"errorMessage":"Error generating redirects: ${error.message}","messagePattern":"Error generating redirects: (.+?)","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/integrations/vercel/src/index.ts","lineNumber":583,"sourceCode":"\t\t\t\tlet trailingSlash: boolean | undefined;\n\t\t\t\t// Vercel's `trailingSlash` option maps to Astro's like so:\n\t\t\t\t// - `true` -> `\"always\"`\n\t\t\t\t// - `false` -> `\"never\"`\n\t\t\t\t// - `undefined` -> `\"ignore\"`\n\t\t\t\t// If config is set to \"ignore\", we leave it as undefined.\n\t\t\t\tif (_config.trailingSlash && _config.trailingSlash !== 'ignore') {\n\t\t\t\t\t// Otherwise, map it accordingly.\n\t\t\t\t\ttrailingSlash = _config.trailingSlash === 'always';\n\t\t\t\t}\n\n\t\t\t\tconst { routes: redirects = [], error } = getTransformedRoutes({\n\t\t\t\t\ttrailingSlash,\n\t\t\t\t\trewrites: [],\n\t\t\t\t\tredirects: getRedirects(routes, _config),\n\t\t\t\t\theaders: [],\n\t\t\t\t});\n\t\t\t\tif (error) {\n\t\t\t\t\tthrow new AstroError(\n\t\t\t\t\t\t`Error generating redirects: ${error.message}`,\n\t\t\t\t\t\terror.link ? `${error.action ?? 'More info'}: ${error.link}` : undefined,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tlet images: VercelImageConfig | undefined;\n\t\t\t\tif (imagesConfig) {\n\t\t\t\t\timages = {\n\t\t\t\t\t\t...imagesConfig,\n\t\t\t\t\t\tdomains:\n\t\t\t\t\t\t\timagesConfig.domains || _config.image.domains\n\t\t\t\t\t\t\t\t? [...(imagesConfig.domains ?? []), ...(_config.image.domains ?? [])]\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\tremotePatterns: [...(imagesConfig.remotePatterns ?? [])],\n\t\t\t\t\t};\n\t\t\t\t\tconst remotePatterns = _config.image.remotePatterns;\n\t\t\t\t\tfor (const pattern of remotePatterns) {\n\t\t\t\t\t\tif (isAcceptedPattern(pattern)) {","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/integrations/vercel/src/index.ts#L565-L601","documentation":"Thrown by the Vercel adapter during `astro:build:done` when `getTransformedRoutes()` (Vercel's route normalizer) returns an `error` object while processing redirects. Astro forwards the message and, if present, a 'More info' link.","triggerScenarios":"A `redirects` config entry that violates Vercel's routing rules (invalid path syntax, too many redirects, circular redirect, unsupported wildcard). A trailing-slash setting that conflicts with redirect definitions. Route count exceeding Vercel plan limits.","commonSituations":"Adding many redirects in `vercel.json` or Astro `redirects`. Mixing `trailingSlash: 'always'` with redirect targets that lack trailing slashes. Hitting Vercel plan route caps.","solutions":["Read the embedded `error.message`/`error.link` — Vercel states the specific rule violated.","Simplify the `redirects` config and re-add entries incrementally to isolate the offender.","Align `trailingSlash` config with redirect destination paths."],"exampleFix":"// before: redirect destination missing trailing slash while trailingSlash: 'always'\nexport default defineConfig({\n  trailingSlash: 'always',\n  redirects: { '/old': '/new' },\n});\n// after\nexport default defineConfig({\n  trailingSlash: 'always',\n  redirects: { '/old': '/new/' },\n});","handlingStrategy":"try-catch","validationCode":"const { error } = getTransformedRoutes({ /* ... */ });\nif (error) { console.error('Redirect rule violated:', error.message, error.link); }","typeGuard":"function hasRouteError(r: unknown): r is { error: { message: string; link?: string } } {\n  return !!(r as any)?.error;\n}","tryCatchPattern":"try { /* build */ } catch (e) { if (/Error generating redirects/) { /* inspect e.message, fix redirects */ } else throw e; }","preventionTips":["Keep redirect rules simple and unique.","Align `trailingSlash` with redirect destinations.","Validate redirects against Vercel limits before deploy."],"tags":["vercel","redirects","routing","build"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}