“无效的主机头”在运行React App时 [英] "Invalid Host Header" in When running React App

查看:92
本文介绍了“无效的主机头”在运行React App时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的React JS项目,并且正在部署到OSE中。我也在项目中使用以下依赖项。

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-dev-server": "^1.14.1",
 "react": "^15.5.4",
 "react-router-dom": "^4.1.1"

我也在通过以下构建脚本运行项目。

also I am running my project through below build script.

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

在OSE中一切正常,Webpack编译成功。但是在访问URL时,它在网页上显示 Invalid Host Header。

Everything goes fine in OSE and Webpack is compiled successfully. But on accessing the url it shows "Invalid Host Header" on the webpage.

任何人都可以帮忙。 React的一些新功能。

Could anyone help on this. Somewhat New in React.

预先感谢。

推荐答案

在您的webpack配置中,您可以在 devServer 配置中添加 disableHostCheck:true 。例如,

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

devServer: {
  disableHostCheck: true
}

这篇关于“无效的主机头”在运行React App时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆