“Invalid Host Header” in When running React App

喜夏-厌秋 提交于 2019-12-03 05:34:56

At your webpack config, you could add disableHostCheck: true at devServer configuration. For example,

devServer: {
  disableHostCheck: true
}

Just to explain why this is happening.

webpack-dev-server has released v2.4.3.

Quoting their patch note:

The Host header of the request have to match the listening adress or the host provided in the public option. Make sure to provide correct values here.

They have also included disableHostCheck to turn this check off, BUT

Only use it when you know what you do. Not recommended.

change the host to 127.0.0.1 in build script.

"build": "SET NODE_ENV=production && webpack-dev-server --host 127.0.0.1 --inline --history-api-fallback --content-base . "

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!