Skip to content

Server Routing Redirect Ignores Guards #60957

@Char2sGu

Description

@Char2sGu

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

Don't known / other

Is this a regression?

No

Description

The below routing configuration always leads to a 302 redirection to /dashboard even though the isAuthenticated guard returns false.

  {
    path: '',
    pathMatch: 'full',
    canMatch: [isAuthenticated],
    redirectTo: 'dashboard',
  },
  {
    path: '',
    pathMatch: 'full',
    redirectTo: 'login',
  },

According to https://angular.dev/guide/hybrid-rendering#customizing-build-time-prerendering-ssg:

Angular handles redirects specified by the redirectTo property in route configurations, differently on the server-side.

Server-Side Rendering (SSR) Redirects are performed using standard HTTP redirects (e.g., 301, 302) within the server-side rendering process.

I assume this is a buggy behavior that accidentally ignored the guards of the redirection route.

Please provide a link to a minimal reproduction of the bug

I will provide if further investigation is needed

Please provide the exception or error you saw

NA

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

Angular CLI: 19.2.6
Node: 22.3.0
Package Manager: npm 10.8.1
OS: linux x64

Angular: 19.2.5
... animations, common, compiler, compiler-cli, core, elements
... forms, localize, platform-browser, platform-server, router
... service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.6
@angular-devkit/build-angular   19.2.6
@angular-devkit/core            19.2.6
@angular-devkit/schematics      19.2.6
@angular/build                  19.2.6
@angular/cdk                    19.2.8
@angular/cli                    19.2.6
@angular/google-maps            19.2.8
@angular/material               19.2.8
@angular/pwa                    19.2.6
@angular/ssr                    19.2.6
@angular/youtube-player         19.2.8
@schematics/angular             19.2.6
ng-packagr                      19.2.1
rxjs                            7.8.1
typescript                      5.7.3
zone.js                         0.15.0

Anything else?

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions