Description
Command
build
Description
Hello everyone,
I'm currently trying to migrate an Angular 18 app with SSR enabled using CommonEngine. After switching to V19 I wanted to move to AngularNodeAppEngine
to be able to have hybrid rendering but I'm facing an issue with dynamic route paths.
The app we are working on, by default, has no pre-defined route paths. They all come from an API. The end user can edit all the slugs of its app on a dedicated interface.
So, during APP_INITIALIZER
we fetch the routes from the API and Router.resetConfig
.
This is working using CommonEngine
.
But it doesn't when using AngularNodeAppEngine because of the route extraction phase during build time to feed the Manifest in this scenario.
When the app is built, let's say the end user has only activated one route routeA
. The server manifest has only a route.
But after some time, the end user chose to add another route to the app (routeB
). During APP_INITIALIZER
the route is correctly added to the router config, but since it's not part of the manifest, routeB
leads to a 404 on SSR.
Minimal Reproduction
I added a repo to highlight the issue : https://github.com/jimjim2a/ssr-dynamic-routing.
Here are the steps to reproduce the issue :
- Build the app -> at this time route extraction knows only "article" route
- open the "/article" page -> During app initializer we now add a second route ("video")
- Click on the "Go to Video page !" button -> This works since the second route is added on CSR
- Refresh the "/video" page -> This path can not be found and leads to a 404
We are in case there both SSR and CSR Router has correct configuration, but since the manifest extracted during build time is not complete, the SSR of the newly added route leads to 404.
Your Environment
Angular CLI: 19.0.6
Node: 20.14.0
Package Manager: npm 10.7.0
OS: darwin 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
Thanks everyone for all the great Job you're doing !