在localhost子域上运行Create React App时无效的Host标头 [英] Invalid Host header when running Create React App on localhost subdomain
问题描述
更新到react-scripts 1.0.0之后,当我尝试在本地主机子域上的浏览器中打开我的应用程序时收到此错误:无效的主机标头
After updating to the react-scripts 1.0.0 I get this error when I try to open my app in the browser on a localhost subdomain: 'Invalid Host header'
我的应用设置为不同子域提供不同的数据:
group1.localhost:3000
group2.localhost:3000
...
My app was set up to serve different data for different subdomains: group1.localhost:3000 group2.localhost:3000 ...
我发现将以下代码添加到我的webpack配置中应该可以解决问题。
I found that adding the code below to my webpack config should fix the problem.
devServer: {
disableHostCheck: true
}
但是我如何在CRA中修复它而不弹出?
But how can i fix it in CRA without ejecting?
推荐答案
请更新至 react-scripts@1.0.2
。< br>
它为那些不使用React中的代理
功能的用户解决了此问题。
Please update to react-scripts@1.0.2
.
It fixes this issue for users who don't use the proxy
feature in React.
如果您愿意使用代理
功能,请按照这些说明进行操作。
这篇关于在localhost子域上运行Create React App时无效的Host标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!