Skip to content

Prerendering via "routesFile" with i18n no longer prerenders index.html, produces infinite "Redirecting" loop (since @angular/ssr 20.3.7) #31877

@anisabboud

Description

@anisabboud

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:

  1. ng new test-prerender-i18n --style=scss --ssr --zoneless --ai-config=none
  2. cd test-prerender-i18n
  3. ng add @angular/localize
  4. echo "/" > prerender-routes.txt
  5. Edit app.routes.ts, use the following content:
    import { Routes } from '@angular/router';
    import { App } from './app';
    
    export const routes: Routes = [
      { path: '', component: App }
    ];
  6. 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)
  7. Run ng build
  8. Try the build: npx serve dist/test-prerender-i18n/browser/
    then open Chrome http://localhost:3000/en => infinite redirect loop
  9. 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.6 of @angular/ssr => Prerendering works.
    npm i @angular/[email protected] && ng build && cat dist/test-prerender-i18n/browser/en/index.html
  • Try version 20.3.7 of @angular/ssr => Redirecting...
    npm i @angular/[email protected] && ng build && cat dist/test-prerender-i18n/browser/en/index.html

Culprit

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions