angular / angular-cli

CLI tool for Angular
https://cli.angular.dev
MIT License
26.79k stars 11.98k forks source link

Angular 19 SSR nested redirectTo result in a redirect loop #28903

Closed ManuelRauber closed 3 days ago

ManuelRauber commented 5 days ago

Which @angular/* package(s) are the source of the bug?

router

Is this a regression?

Yes

Description

Using the following routes in Angular 19 with SSR enables leads to an ERR_TOO_MANY_REDIRECTS error:

export const routes: Routes = [
  {
    path: '',
    pathMatch: 'full',
    redirectTo: 'some',
  },
  {
    path: ':param',
    children: [
      {
        path: '',
        pathMatch: 'full',
        redirectTo: 'thing',
      },
      {
        path: 'thing',
        component: ExampleComponent,
      }
    ]
  }
];

The behavior in Angular 18 SSR: If you go to / you're redirected to /some which redirects to /some/thing. The behavior in Angular 19 SSR: If you go to / you get stuck in a redirect loop which tries to redirect to /thing. So, it looks like the nested redirect is not adding the parent route but tries redirect to a root route.

The same routing works in Angular 19 without SSR.

Please see the linked example and read the README there for setting up the example.

Please provide a link to a minimal reproduction of the bug

https://github.com/ManuelRauber/angular-19-ssr-redirect-issue

Please provide the exception or error you saw

`ERR_TOO_MANY_REDIRECTS` in the browser.

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 19.0.0
Node: 20.17.0
Package Manager: npm 10.8.2
OS: darwin arm64

Angular: 19.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1900.0
@angular-devkit/build-angular   19.0.0
@angular-devkit/core            19.0.0
@angular-devkit/schematics      19.0.0
@schematics/angular             19.0.0
rxjs                            7.8.1
typescript                      5.6.3
zone.js                         0.15.0

Anything else?

No response