-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Labels
area: @angular/buildfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity5: regressiontype: bug/fix
Description
Command
build
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
20.3.6
Description
Using angular.json "prerender": { "routesFile": "...", "discoverRoutes": false }, in combination with "i18n": { ... } and "localize", no longer prerenders locale/index.html properly.
Minimal Reproduction
Follow the following minimal reproduction steps:
ng new test-prerender-i18n --style=scss --ssr --zoneless --ai-config=nonecd test-prerender-i18nng add @angular/localizeecho "/" > prerender-routes.txt- Edit
app.routes.ts, use the following content:import { Routes } from '@angular/router'; import { App } from './app'; export const routes: Routes = [ { path: '', component: App } ];
- Edit
angular.json:- Under
"projects" > "test-prerender-i18n", add:"i18n": { "sourceLocale": "en" },
- Under
"configurations" > "production", add"prerender": { "routesFile": "prerender-routes.txt", "discoverRoutes": false }, "localize": ["en"],
- Remove
"outputMode": "server",(doesn't work with prerender)
- Under
- Run
ng build - Try the build:
npx serve dist/test-prerender-i18n/browser/
then open Chrome http://localhost:3000/en => infinite redirect loop cat dist/test-prerender-i18n/browser/en/index.html
You will see the following HTML with infinite Redirecting loop, instead of actual prerendered content:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting</title>
<meta http-equiv="refresh" content="0; url=/en">
</head>
<body>
<pre>Redirecting to <a href="/en">/en</a></pre>
</body>
</html>Exception or Error
Redirecting
Your Environment
Angular CLI: 20.3.11
Node: 22.16.0
Package Manager: npm 11.6.2
OS: linux x64
Anything else relevant?
- The issue affects the root route only ("/") i.e., the homepage.
Other routes (such as /blog) seem to get prerendered just fine. - Can reproduce only with
"discoverRoutes": false
Regression 20.3.6 -> 20.3.7
- Try version
20.3.6of@angular/ssr=> Prerendering works.
npm i @angular/[email protected] && ng build && cat dist/test-prerender-i18n/browser/en/index.html - Try version
20.3.7of@angular/ssr=> Redirecting...
npm i @angular/[email protected] && ng build && cat dist/test-prerender-i18n/browser/en/index.html
Culprit
- https://github.com/angular/angular-cli/releases/tag/20.3.7 → Might be caused by 5db6d64
- Also related: SSG generates empty index.html if navigation in guard #31618
(A different issue also since20.3.7about missingindex.htmlin some cases; no mention of i18n.) - Note: The issue also reproduces with the upcoming version
21.0.0:
ng update @angular/core@next @angular/cli@next
ng build && cat dist/test-prerender-i18n/browser/en/index.html=> Same issue.
Metadata
Metadata
Assignees
Labels
area: @angular/buildfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity5: regressiontype: bug/fix