“Invalid Host Header” in When running React App

后端 未结 3 721
面向向阳花
面向向阳花 2021-02-05 10:39

I am having one simple project of React JS and I am deploying into OSE. Also I am using below dependencies in my project.

 \"webpack\": \"^2.2.0\",
 \"webpack-de         


        
相关标签:
3条回答
  • 2021-02-05 11:12

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

    devServer: {
      disableHostCheck: true
    }
    
    0 讨论(0)
  • 2021-02-05 11:17

    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.

    0 讨论(0)
  • 2021-02-05 11:28

    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 . "

    0 讨论(0)
提交回复
热议问题