X Tutup
Skip to content

Strict host header validation breaks route extraction #32730

@JJWesterkamp

Description

@JJWesterkamp

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.13

Description

Since an update of @angular/cli from 20.3.13 to 20.3.19, "extracting routes" fails when running ng build. The route extraction procedure boots an Angular app wherein my server.ts file requires certain process.env keys to exist, and otherwise throws an error. These variables used to be inherited from the parent process but no longer are.

I have pinpointed the issue to #32516, where in prerender.ts new keys env are set inside constructor options for WorkerPool, which changes the behavior of lines 33-39 of WorkerPool that now hits the if branch instead of the else branch.

I have confirmed this is the case by changing the blocks in prerender.ts as follows:

    env: {
++    ...process.env,
      'NG_ALLOWED_HOSTS': 'localhost',
    },

Is this intended behavior? If so, how do I fix it given that all of this looks to be internal angular builder logic?

Thanks!

Minimal Reproduction

Add a block to server.ts:

if (! process.env.TEST) {
  throw new Error('oops');
}

run the following command:

TEST=true npx ng build

Exception or Error

✘ [ERROR] An error occurred while extracting routes.

oops

Your Environment

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



Angular CLI: 20.3.19
Node: 24.3.0
Package Manager: npm 11.4.2
OS: darwin arm64


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

Package                         Version
---------------------------------------
@angular-devkit/architect       0.2003.19
@angular-devkit/build-angular   20.3.19
@angular-devkit/core            20.3.19
@angular-devkit/schematics      20.3.19
@angular/build                  20.3.19
@angular/cdk                    20.2.4
@angular/cli                    20.3.19
@angular/material               20.2.4
@angular/ssr                    20.3.19
@schematics/angular             20.3.19
rxjs                            7.8.2
typescript                      5.9.2
zone.js                         0.15.1

Anything else relevant?

I'm using Angular SSR.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup