Skip to content

Routes beginning with Dynamic Parameters break Angular Prerendering and SSR #29452

Closed
@robertsine

Description

@robertsine

Command

build, 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

No response

Description

Angular provides examples on how to use prerendering for parametrized routes like post/:id. However, in our project, we have routes with dynamic parameters at the beginning of the route path, such as :seoAlias/:category/:offerId.

This specific route structure causes issues in Client, Server, and Prerender modes, breaking other routes when serving the app in development mode or building the application.

Minimal Reproduction

We have created a simple reproduction repository:
https://github.com/robertsine/car-shop

Inside the file app.routes.server.ts there are several route variants. By uncommenting them, you can reproduce the issue. Notably, only offers/:slug works well. Other server routes are breaking entire app, when serving app in dev mode or serving build.

We tried to use the ** path as a hack to prerender our parameterized routes. However, in development mode, it does not work. In build mode, it creates prerendered pages. For note, we must ensure unique parameters across the entire route configuration to avoid hitting several paths with same parameter name. However, it generates fallback content inside the index files.

Exception or Error

Error: Error(s) occurred while extracting routes:
- The '' server route does not match any routes defined in the Angular routing configuration (typically provided as a part of the 'provideRouter' call). Please make sure that the mentioned server route is present in the Angular routing configuration.

Your Environment

Angular CLI: 19.0.6
Node: 22.13.1
Package Manager: npm 9.5.1
OS: win32 x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1900.6
@angular-devkit/build-angular   19.0.6
@angular-devkit/core            19.0.6
@angular-devkit/schematics      19.0.6
@angular/cli                    19.0.6
@angular/ssr                    19.0.6
@schematics/angular             19.0.6
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