-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Invalid Host header after updating to 1.0.1 #6070
Comments
same here, runs on debian |
same here on OSX. |
Maybe it related to? |
It's indeed due to a security fix added lately to webpack-dev-server. You must start with |
@amiram I had to add some trickery to my hosts file, and serve from a name, but it is indeed the curlpit. |
@SanderElias there is a new option in webpack disableHostCheck that will also solve it. Can I set it if I'm using angular cli? |
@amiram Nope, it's not exported to cmd-line yet afaik. Seems even impossible from webpack cmd-line itself for now. |
In the details of this Webpack security update, there's an important note:
It means what it means. If you were using just a webpack-dev-server and localhost hostname or 127.0.0.1 to develop/test an app in your browser, you should be fine. But if you were using it behind a hostname (e.g. myapp.com) while the NG CLI or Webpack dev server served your app from the default address, and you proxied requests to it from, let's say, Nginx, then the whole HTTP header forwarding path must be matched. I left an example in the previously linked issue - webpack/webpack-dev-server#882 (comment) |
Seems like specifying |
I have multitenant system .SO in 1.0.0 version when I was adding subdomain It was working. But now It is giving me Invalid host header. |
@vivekamin edit your hosts file is the easiest. The dev server is not meant to be used in production. This a secutiry measure taken by the webpack team. There is little no nothing the CLI team can do, execpt from exposing the switched spoken about above! |
@SanderElias which hosts file? Can you please elaborate. Is it nginx hosts files? How to do It in development environment ? |
Adding |
This is a problem for me too. I use two separate IDEs and applications, one for Angular and one for the web services. The Angular app will deploy to S3 and the services to Elastic Beanstalk, and I simulate this locally with myapp.lvh.me:4200 and myservices.lvh.me:4300 was working great until I upgraded to Angular 4 and latest angular-cli |
@AaronLangley Degrade to Angular-CLI 1.0.0 which has Angular V4, will solve problem. I am still figuring out the way for development purspose. |
@dinvlad I am developing multitenant Sys .So subdomain may change whatever. How can I put a regex for same in hosts files. I am confused. |
@vivekamin - maybe a child object/section in .angular-cli.json that maps to webpack.config.js ? Was just looking at this SO post for reactjs |
I'm reopening this issue, because it's seems a major inconvienece to developers that the needed switches are not available in the CLI. |
Until this gets resolved you can just change the following line in node_modules/webpack-dev-server/lib/Server.js (line 402):
change to
|
Or you can just give disableHostCheck : false, in webpackDevServer config
in serve.js file in tasks folder of cli. node_modules/@angular/cli
|
Even using |
It's working with - - host 0.0.0.0. What's your use case? |
That doesn't work. At least behind a proxy. |
Having same problem within my dev env. I run my IDE on linux VM, and then access to that from my windows machine. With 1.0.0 angular-cli this could be solved just by using host 0.0.0.0, but now this won't work :( It would be nice if there was a simple option for ng serve to make this work just like previously. |
imho changing code under |
I checked the version of webpack I used and already have the fix at line 402. However angular app still does not work in current verison of cloud9 ide. Below is my package.json
|
@kktam, my current workaround is to add |
Two new flags are added to `ng serve`: - `--public-host` (aliased by `--live-reload-client): Specify the URL that the browser client will use. - `--disable-host-check`: Don't verify connected clients are part of allowed hosts. Setting `--disable-host-check` will output a warning: ``` WARNING Running a server with --disable-host-check is a security risk. See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a for more information. ``` See angular#6070 for more context about this change. Fix angular#6070
Two new flags are added to `ng serve`: - `--public-host` (aliased by `--live-reload-client): Specify the URL that the browser client will use. - `--disable-host-check`: Don't verify connected clients are part of allowed hosts. Setting `--disable-host-check` will output a warning: ``` WARNING Running a server with --disable-host-check is a security risk. See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a for more information. ``` See angular#6070 for more context about this change. Fix angular#6070
Two new flags are added to `ng serve`: - `--public-host` (aliased by `--live-reload-client): Specify the URL that the browser client will use. - `--disable-host-check`: Don't verify connected clients are part of allowed hosts. Setting `--disable-host-check` will output a warning: ``` WARNING Running a server with --disable-host-check is a security risk. See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a for more information. ``` See angular#6070 for more context about this change. Fix angular#6070
Two new flags are added to `ng serve`: - `--public-host` (aliased by `--live-reload-client): Specify the URL that the browser client will use. - `--disable-host-check`: Don't verify connected clients are part of allowed hosts. Setting `--disable-host-check` will output a warning: ``` WARNING Running a server with --disable-host-check is a security risk. See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a for more information. ``` See angular#6070 for more context about this change. Fix angular#6070
Two new flags are added to `ng serve`: - `--public-host` (aliased by `--live-reload-client): Specify the URL that the browser client will use. - `--disable-host-check`: Don't verify connected clients are part of allowed hosts. Setting `--disable-host-check` will output a warning: ``` WARNING Running a server with --disable-host-check is a security risk. See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a for more information. ``` See angular#6070 for more context about this change. Fix angular#6070
Two new flags are added to `ng serve`: - `--public-host` (aliased by `--live-reload-client): Specify the URL that the browser client will use. - `--disable-host-check`: Don't verify connected clients are part of allowed hosts. Setting `--disable-host-check` will output a warning: ``` WARNING Running a server with --disable-host-check is a security risk. See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a for more information. ``` See angular#6070 for more context about this change. Fix angular#6070
Two new flags are added to `ng serve`: - `--public-host` (aliased by `--live-reload-client): Specify the URL that the browser client will use. - `--disable-host-check`: Don't verify connected clients are part of allowed hosts. Setting `--disable-host-check` will output a warning: ``` WARNING Running a server with --disable-host-check is a security risk. See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a for more information. ``` See #6070 for more context about this change. Fix #6070
The 0.0.0.0 host format will never work with current webpack version and will always show "invalid host header". Instead, a valid domain or public IP has to be specified. See angular#6070 .
@flackjap Adding return true to checkHost does work for me, bu return an error : Could not connect to REST server. Please check your configuration details |
@rahianeja This issue has been solved and closed. #6173 If you still have to use the older version, then change the disableHostCheck to false, in webpackDevServer config file. |
solution for me in cloud9: |
@jrohatiner no need for that, I use mine in Cloud9 too without any modifications to the source code. Just use |
@rahianeja @flackjap Did you manage to solve your problem? I'm having the same thing. I can access my app with the --disable-host-check from the internet but I get the "Error: Could not connect to REST server. Please check your configuration details". It works locally with no issues. |
Where do you get that error from? Angular CLI? Browser? Something else? |
@flackjap Sorry for being unspecific. I'm following the tutorial to setup a hyperledger app over here. Part of that is generating a REST server and an Angular Skeleton application with Yeoman ontop. I have addedd the --disable-host-check which solves the problem of "Invalid host header" but I'm now running in to an error in the browser when I try to interact with the REST API from the app. The rest API works by itself and the interaction works when I use it on the local machine (localhost:4200). |
@flackjap @rahianeja I solved it. Was an easy fix. I needed to edit the file: my-app/src/app/configuration.ts. The line |
@kimfrithiof I am having the same issue as you however changing the line |
I don't know what you guys are trying to do, but it seems that it has nothing to do with Angular CLI. |
This situation has happened to me while trying to have a docker apache httpd work as a reverse proxy to my localhost nodejs . The message popped up in my browser saying that the hostname was invalid, but not clarifying what hostname was being used. A hurdle for development. I am going to modify the To contain the docker Mac localhost. |
Two new flags are added to `ng serve`: - `--public-host` (aliased by `--live-reload-client): Specify the URL that the browser client will use. - `--disable-host-check`: Don't verify connected clients are part of allowed hosts. Setting `--disable-host-check` will output a warning: ``` WARNING Running a server with --disable-host-check is a security risk. See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a for more information. ``` See angular#6070 for more context about this change. Fix angular#6070
this saved me after many hours of surfing for the solution |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Versions.
1.0.1
Repro steps.
update to 1.0.1
ng serve
browser will read: Invalid Host header, and do nothing
The log given by the failure.
none
Desired functionality.
serve my application.
Mention any other details that might be useful.
Downgrading to 1.0.0 fixed the issue. (BTW, running on ubuntu and debian, same issue)
The text was updated successfully, but these errors were encountered: