angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng serve ignores public-host when live reload disabled

Open shawnweeks opened this issue 2 years ago • 0 comments

Command

serve

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

No response

Description

For the test I setup an /etc/hosts entry for test.example.local pointing at 127.0.0.1 to simulate running ng serve behind a reverse proxy.

When running ng serve behind a reverse proxy where the public-host is not localhost you will receive and invalid host header if you disable live reload with --no-live-reload or --live-reload=false

Minimal Reproduction

Add an /etc/hosts entry for test.example.local then run the following.

ng new public-host-test # Use all default options
cd public-host-test
ng serve --public-host test.example.local --no-live-reload

Then open a browser and try to access the app at http://test.example.local:4200 where you'll notice the Invalid Host header error, if I leave live reload enabled this all works fine. I've confirmed this behavior on MacOS and RHEL 8.

Exception or Error

No response

Your Environment

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


Angular CLI: 16.2.3
Node: 16.18.0
Package Manager: npm 9.6.5
OS: darwin arm64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1602.3
@angular-devkit/build-angular   16.2.3
@angular-devkit/core            16.2.3
@angular-devkit/schematics      16.2.3
@angular/cli                    16.2.3
@schematics/angular             16.2.3
rxjs                            7.8.1
typescript                      5.1.6
zone.js                         0.13.3


### Anything else relevant?

_No response_

shawnweeks avatar Sep 20 '23 15:09 shawnweeks