Skip to content

Strict host header validation breaks route extraction #32730

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.

Activity

  1. added 2 commits that reference this issue on Mar 10, 2026
    275eded
    0522c48
  2. added theissue type on Mar 10, 2026
  3. added 2 commits that reference this issue on Mar 10, 2026
    7d519d8
    9d53588
  4. added 2 commits that reference this issue on Mar 10, 2026
    067748a
    a138797
  5. added 4 commits that reference this issue on Mar 11, 2026
    0fd6823
    8b52fb2
    839c725
    58688eb
  6. angular-automatic-lock-bot commented on Apr 11, 2026

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  7. locked and limited conversation to collaborators on Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions