Skip to content

AngularNodeAppEngine has different unknown path routing behavior than CommonEngine #29539

Closed
@griest024

Description

@griest024

Command

serve

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

18

Description

When the routing configuration contains a nested wildcard route and a redirect target and an non-nested wildcard route after the nested route that redirects to the nested route (see below), CommonEngine will use the nested route while AngularNodeAppEngine will use the non-nested route.

@Component({selector: 'test', template: 'test'})
class TestComponent {}

@Component({selector: 'not-found', template: '404 not found'})
class NotFoundComponent {}

export const routes: Routes = [
  {
    path: '',
    children: [
      // AngularNodeAppEngine will end up following the redirect and rendering this route
      {
        path: 'not-found',
        component: NotFoundComponent
      },
      // CommonEngine will just simply render this route
      {
        path: '**',
        component: TestComponent
      },
    ]
  },
  // AngularNodeAppEngine chooses this route
  {
    path: '**',
    redirectTo: 'not-found'
  },
]

Is this intended behavior? It seems that the vite dev server follows the behavior of AngularNodeAppEngine and is blocking us from upgrading to v19.

Something odd is that AngularNodeAppEngine will render / as test but /asdfasdf as 404 not found. CommonEngine renders test for both of these paths.

Some debugging found that

routesResults.push(result);
is likely to blame. It flattens the route tree in a way that the nested wildcard route gets overridden by the non-nested one during the insert into the final route tree
routeTree.insert(fullRoute, metadata);

Minimal Reproduction

AngularNodeAppEngine - https://github.com/griest024/ng19-server-routing
CommonEngine - https://github.com/griest024/ng19-server-routing/tree/common-engine

  1. run npx ng b && npm run serve:ssr:19-dev-server-routes
  2. navigate to /asdfasdfasdf or any other route that is not / or /not-found
  3. See that the rendered component is different.

Exception or Error


Your Environment

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

Angular CLI: 19.1.5
Node: 18.20.5
Package Manager: npm 10.8.2
OS: linux x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1901.5
@angular-devkit/build-angular   19.1.5
@angular-devkit/core            19.1.5
@angular-devkit/schematics      19.1.5
@angular/cli                    19.1.5
@angular/ssr                    19.1.5
@schematics/angular             19.1.5
rxjs                            7.8.1
typescript                      5.6.3
zone.js                         0.15.0

Anything else relevant?

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions