Skip to content

e2e respects publilcHost, but serve changes publicHost setting #14297

Closed
@qlonik

Description

@qlonik

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [x] serve
- [ ] test
- [x] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

I dont know

Description

As it is now, e2e command is respecting the publicHost setting from serve command, and based on that it sets the baseUrl which is used by tests:

if (typeof serverOptions.publicHost === 'string') {
let publicHost = serverOptions.publicHost as string;
if (!/^\w+:\/\//.test(publicHost)) {
publicHost = `${serverOptions.ssl
? 'https'
: 'http'}://${publicHost}`;
}
const clientUrl = url.parse(publicHost);
baseUrl = url.format(clientUrl);

However, the serve command itself modifies this value, and is getting rid of everything in the path, other than host:

options.publicHost = clientAddress.host;

Is it possible for the serve command to keep the configuration option intact? This way the baseUrl for e2e test run will be created correctly.

Alternatively, the value of baseUrl option passed in protractor config could be respected, and concatenated with the calculated host from publicHost option. However, this way there is duplicate configuration: base url will be specified both for serve command and for e2e command.

🔬 Minimal Reproduction

To reproduce, set the serve configuration options as following:

"options": {
    "browserTarget": "myapp:build",
    "baseHref": "/custom-namespace/",
    "publicHost": "https://localhost/custom-namespace/"
}

Then run ng e2e.

🔥 Exception or Error

The browser will open with URL: https://localhost/ instead of https://localhost/custom-namespace/

🌍 Your Environment

It seems that my environment is older compared to the latest commit in this repository. However, it seems that the behaviour is largely similar, and publicHost is modified in the same way in older and newer versions.


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

Angular CLI: 7.3.8
Node: 11.12.0
OS: win32 x64
Angular: 7.2.12
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.13.8
@angular-devkit/build-angular      0.13.8
@angular-devkit/build-optimizer    0.13.8
@angular-devkit/build-webpack      0.13.8
@angular-devkit/core               7.3.8
@angular-devkit/schematics         7.3.8
@angular/cdk                       7.3.7
@angular/cli                       7.3.8
@angular/flex-layout               7.0.0-beta.24
@angular/material                  7.3.7
@angular/material-moment-adapter   7.3.7
@ngtools/webpack                   7.3.8
@schematics/angular                7.3.8
@schematics/update                 0.13.8
rxjs                               6.4.0
typescript                         3.2.4
webpack                            4.29.0

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions