Skip to content

SSR redirects a redirectTo that uses a route parameter to the literal :id instead of the parameter value #34410

Closed

Description

@MeAkib

Command

serve, build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

With server rendering, a route whose redirectTo reuses one of its own route parameters is redirected to the literal parameter name. The Angular router substitutes the matched parameter on the client:

export const routes: Routes = [
  { path: 'old/:id', redirectTo: 'new/:id' },
  { path: 'new/:id', component: Detail },
];
  • Client-side navigation to /old/5 ends up at /new/5.
  • A server-rendered request for /old/5 responds 302 with Location: /new/:id.

resolveRedirectTo in packages/angular/ssr/src/routes/ng-routes.ts replaces parameters of the parent route with *, but leaves :id in the redirectTo string unchanged. buildPathWithParams in packages/angular/ssr/src/utils/url.ts then only fills * segments from the request path, so the :id placeholder is never replaced.

Minimal Reproduction

ng new repro --ssr --defaults   # outputMode: server

Routes as above, serverRoutes with { path: '**', renderMode: RenderMode.Server }, then:

ng build && node dist/repro/server/server.mjs
curl -i http://localhost:4000/old/5

Exception or Error

HTTP/1.1 302 Found
Location: /new/:id

Expected `Location: /new/5`.

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI       : 22.0.5
Node.js           : 24.15.0
Package Manager   : yarn 1.22.22
Operating System  : darwin arm64

Anything else relevant?

No response

Activity

  1. added this to the needsTriage milestone on Oct 20, 2026
  2. alan-agius4 commented on Oct 26, 2026

    @alan-agius4
    Collaborator

    Closed via #34321

  3. angular-automatic-lock-bot commented on Nov 29, 2026

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  4. locked and limited conversation to collaborators on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions