I am getting an “Invalid Host header” message when connecting to webpack-dev-server remotely

后端 未结 10 1968
粉色の甜心
粉色の甜心 2020-12-02 04:57

I am using as an environment, a Cloud9.io ubuntu VM Online IDE and I have reduced by troubleshooting this error to just running the app with Webpack dev server.

I l

10条回答
  •  离开以前
    2020-12-02 05:33

    Hello React Developers,

    Instead of doing this disableHostCheck: true, in webpackDevServer.config.js. You can easily solve 'invalid host headers' error by adding a .env file to you project, add the variables HOST=0.0.0.0 and DANGEROUSLY_DISABLE_HOST_CHECK=true in .env file. If you want to make changes in webpackDevServer.config.js, you need to extract the react-scripts by using 'npm run eject' which is not recommended to do it. So the better solution is adding above mentioned variables in .env file of your project.

    Happy Coding :)

提交回复
热议问题