{"record":{"id":"29ae28fe18126c12","repo":"angular/angular","slug":"named-outlet-redirect","errorCode":"NAMED_OUTLET_REDIRECT","errorMessage":"Only absolute redirects can have named outlets. redirectTo: '${redirectTo}'","messagePattern":"Only absolute redirects can have named outlets\\. redirectTo: '(.+?)'","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"packages/router/src/apply_redirects.ts","lineNumber":46,"sourceCode":"    // when extending errors in TS and the workaround is to explicitly set the prototype.\n    // https://stackoverflow.com/questions/41102060/typescript-extending-error-class\n    Object.setPrototypeOf(this, NoMatch.prototype);\n  }\n}\n\nexport class AbsoluteRedirect extends Error {\n  constructor(public urlTree: UrlTree) {\n    super();\n\n    // Extending `Error` ends up breaking some internal tests. This appears to be a known issue\n    // when extending errors in TS and the workaround is to explicitly set the prototype.\n    // https://stackoverflow.com/questions/41102060/typescript-extending-error-class\n    Object.setPrototypeOf(this, AbsoluteRedirect.prototype);\n  }\n}\n\nexport function namedOutletsRedirect(redirectTo: string): never {\n  throw new RuntimeError(\n    RuntimeErrorCode.NAMED_OUTLET_REDIRECT,\n    (typeof ngDevMode === 'undefined' || ngDevMode) &&\n      `Only absolute redirects can have named outlets. redirectTo: '${redirectTo}'`,\n  );\n}\n\nexport function canLoadFails(route: Route): never {\n  throw navigationCancelingError(\n    (typeof ngDevMode === 'undefined' || ngDevMode) &&\n      `Cannot load children because the guard of the route \"path: '${route.path}'\" returned false`,\n    NavigationCancellationCode.GuardRejected,\n  );\n}\n\nexport class ApplyRedirects {\n  constructor(\n    private urlSerializer: UrlSerializer,\n    private urlTree: UrlTree,","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/angular/angular/blob/51cb07e98081ab7e4e84a9e0949266a8e19cca84/packages/router/src/apply_redirects.ts#L28-L64","documentation":"When the router applies route redirects, a redirectTo value containing a named outlet target like 'user(aux:profile)' is only valid for absolute redirects (starting with '/'), because only an absolute redirect can rebuild the full URL tree including outlet segments. namedOutletsRedirect() throws NAMED_OUTLET_REDIRECT when a relative redirect references an outlet.","triggerScenarios":"Route config such as `{path: 'old', redirectTo: 'user(aux:profile)'}` (no leading '/'); any redirectTo string containing `(outlet:...)` that does not start with '/'; navigating to the source route triggers redirect application.","commonSituations":"Converting absolute redirects to relative ones during refactors; copy-pasting outlet URLs from browser links into redirectTo; configuring popup/sidebar outlets via redirects.","solutions":["Make the redirect absolute: `redirectTo: '/user(aux:profile)'`","Or remove the named outlet target from redirectTo and redirect to 'user' only","If you need conditional outlet setup, use a canActivate guard with Router.navigate() instead of redirectTo"],"exampleFix":"// before\n{path: 'old', redirectTo: 'user(aux:profile)'} // relative + named outlet -> throws\n\n// after\n{path: 'old', redirectTo: '/user(aux:profile)'} // absolute -> allowed","handlingStrategy":"validation","validationCode":"// Fail fast at config-definition time instead of at navigation time\nfunction assertRedirectsValid(routes: Routes): void {\n  for (const r of routes) {\n    if (r.redirectTo && !r.redirectTo.startsWith('/') && /\\(.+:.+\\)/.test(r.redirectTo)) {\n      throw new Error(\n        `Route '${r.path}': relative redirect '${r.redirectTo}' cannot target a named outlet; make it absolute`,\n      );\n    }\n    if (r.children) assertRedirectsValid(r.children);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute redirectTo values whenever an outlet target '(name:path)' is present","Lint route configs for outlet syntax in relative redirects in CI"],"tags":["router","redirect","named-outlet","route-config"],"backgroundTag":"invalid-redirect-config","analyzedSha":"51cb07e98081ab7e4e84a9e0949266a8e19cca84","analyzedAt":"2026-08-22T07:04:54.531Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}