【发布时间】:2020-12-26 07:53:38
【问题描述】:
在我对我的 react 应用程序进行最新更改之前,我的网站运行良好。当我部署更改时,网页上会出现“Invalid Host header”。
这是我的代码结构:
我可以配置什么来消除这个错误?
这是我的 package.json 文件:
{
"name": "client",
"proxy": "http://127.0.0.1:4000",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.2",
"@material-ui/icons": "^4.11.2",
"@material-ui/styles": "^4.11.2",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.6.0",
"axios": "^0.21.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
这是我的 pod 的日志:
> client@0.1.0 start
> react-scripts start
ℹ 「wds」: Project is running at http://10.244.1.23/
ℹ 「wds」: webpack output is served from
ℹ 「wds」: Content not from webpack is served from /app/public
ℹ 「wds」: 404s will fallback to /
Starting the development server...
Compiled successfully!
You can now view client in the browser.
Local: http://localhost:3000
On Your Network: http://10.244.1.23:3000
Note that the development build is not optimized.
To create a production build, use npm run build.
谢谢!
【问题讨论】:
-
提供您所做更改的详细信息,否则 package.json 将没有任何用处。
-
从浏览器的网络面板检查主机头的值。它应该是您站点的 DNS 名称。检查你的 pod(s) 的日志,找出更多的故障排除指针。
-
@SameerNaik 嗨 Sameer,我上传了我的 pod 的日志。你觉得有什么问题吗?
标签: reactjs kubernetes digital-ocean