{"record":{"id":"f018f9d0ab18275d","repo":"withastro/astro","slug":"invalidredirectdestination","errorCode":"InvalidRedirectDestination","errorMessage":"The redirect from \"${from}\" to \"${to}\" is invalid. The destination \"${to}\" does not match any existing route in your project.","messagePattern":"The redirect from \"(.+?)\" to \"(.+?)\" is invalid\\. The destination \"(.+?)\" does not match any existing route in your project\\.","errorType":"validation","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/routing/create-manifest.ts","lineNumber":559,"sourceCode":"\t\tif (URL.canParse(destination) && !/^https?:\\/\\//.test(destination)) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...UnsupportedExternalRedirect,\n\t\t\t\tmessage: UnsupportedExternalRedirect.message(from, destination),\n\t\t\t});\n\t\t}\n\n\t\tconst redirectRoute = routeMap.get(destination);\n\n\t\t// If the source has dynamic params and the redirect will be prerendered,\n\t\t// we need a valid redirectRoute to map them. Without it, the build will fail\n\t\t// later with a misleading error. Catch this early and provide a clear error message.\n\t\tif (\n\t\t\tparams.length > 0 &&\n\t\t\t!redirectRoute &&\n\t\t\t!URL.canParse(destination) &&\n\t\t\tgetPrerenderDefault(config)\n\t\t) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...InvalidRedirectDestination,\n\t\t\t\tmessage: InvalidRedirectDestination.message(from, destination),\n\t\t\t});\n\t\t}\n\n\t\t// If the source has dynamic params and the destination route exists but has\n\t\t// fewer params, the build will fail later with a misleading error (e.g.,\n\t\t// \"getStaticPaths required\" pointing at the wrong file). Catch this early.\n\t\tif (\n\t\t\tparams.length > 0 &&\n\t\t\tredirectRoute &&\n\t\t\t!URL.canParse(destination) &&\n\t\t\tgetPrerenderDefault(config)\n\t\t) {\n\t\t\tconst destParams = redirectRoute.params ?? [];\n\t\t\tconst missingParams = params.filter((p) => !destParams.includes(p));\n\t\t\tif (missingParams.length > 0) {\n\t\t\t\tthrow new AstroError({","sourceCodeStart":541,"sourceCodeEnd":577,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/core/routing/create-manifest.ts#L541-L577","documentation":"InvalidRedirectDestination: a redirect whose SOURCE has dynamic params points to a destination that is not a parseable URL and does not match any existing route in the project, while prerenderDefault is on. With dynamic source params, Astro needs a real destination route to map them at build time; an unmapped destination would later fail with a misleading error, so it is caught early.","triggerScenarios":"Configuring redirects: { '/old/[slug]': '/new/[slug]' } when /new/[slug] does not exist; destination is a bare path with no matching page; typo in the destination route.","commonSituations":"Renaming/renaming routes but forgetting to update redirects; redirects pointing to yet-to-be-created pages; copying redirects from another project whose routes differ.","solutions":["Create the destination route so it exists in the project, or correct the typo.","If the destination is a full URL, use http(s):// so URL.canParse treats it as external.","Disable prerendering for the source (prerender = false) so the redirect is resolved at runtime.","Remove the dynamic param from the source if the destination is truly static."],"exampleFix":"// before\nredirects: { '/old/[slug]': '/missing/[slug]' } // /missing/[slug] page absent\n\n// after — create src/pages/missing/[slug].astro, or point to existing route\nredirects: { '/old/[slug]': '/posts/[slug]' }","handlingStrategy":"validation","validationCode":"function destinationRouteExists(dest: string, routes: string[]): boolean {\n  if (URL.canParse(dest)) return true; // external\n  return routes.includes(dest);\n}\n// cross-check dynamic-redirect destinations against the route list","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a single source of truth for routes and validate redirects against it.","When renaming/removing a route, grep config.redirects for references.","Use full URLs for truly external destinations."],"tags":["redirect","config","routing","dynamic-routes"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}