Skip to content

e2e respects publilcHost, but serve changes publicHost setting #14297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
qlonik opened this issue Apr 27, 2019 · 6 comments
Closed

e2e respects publilcHost, but serve changes publicHost setting #14297

qlonik opened this issue Apr 27, 2019 · 6 comments
Labels
Milestone

Comments

@qlonik
Copy link

qlonik commented Apr 27, 2019

🐞 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?

@ngbot ngbot bot added this to the needsTriage milestone Apr 29, 2019
@alan-agius4 alan-agius4 added the freq1: low Only reported by a handful of users who observe it rarely label Apr 29, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog May 2, 2019
@filipesilva
Copy link
Contributor

@alan-agius4 this is similar to #14165 right?

@alan-agius4
Copy link
Collaborator

Similar but this is a different bug which the above mentioned PR won’t address.

@alan-agius4
Copy link
Collaborator

I have been looking at this a bit and it seems that it is running as expected. The PublicHost, option won't open the browser on that given, but rather make it available publicly on the network using that host.

Looking at what you are passing as public-host, I think that you should use server-path instead https://angular.io/cli/serve

That said, the e2e builder is not handling the later option.

@clydin
Copy link
Member

clydin commented May 8, 2019

The issue here appears to be that the dev server's baseUrl result property is not being used when available within the protractor builder. This property provides the full URL to access the configured dev server; including deploy URL, base HREF, and serve path options.

The publicHost option is intended to be used to satisfy HOST header checks or when the client facing URL is different than the address served by the dev server (reverse proxy, for instance). In such scenarios, protractor's baseUrl option would generally be the option of choice as the E2E process will most likely be run independently and potentially on a different machine or container.
The publicHost logic within the protractor builder originated in the 1.x timeframe and should most likely be removed as the baseUrl result property is more accurate in combined serve/e2e scenarios.

@alan-agius4
Copy link
Collaborator

Should have been addressed by #14376

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants