大家好!我对React项目有一个问题。我开发了一个React项目,并在AWS Lightsail服务器上托管。我将React的端口设置为80。
我的网站使用IP地址运行良好,您可以使用以下网址查看我的网站:http://54.80.46.251/
但它不适用于域名。您可以使用以下网址查看我的网站:https://peezee.org/
这是项目的Package.json文件
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@reduxjs/toolkit": "^1.8.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.26.1",
"bootstrap": "^5.1.3",
"ngrok": "^4.3.1",
"node-sass": "^7.0.1",
"react": "^17.0.2",
"react-bootstrap": "^2.2.0",
"react-dom": "^17.0.2",
"react-redux": "^7.2.6",
"react-router-dom": "^6.2.2",
"react-scripts": "5.0.0",
"redux-devtools-extension": "^2.13.9"
},
"scripts": {
"start": "set PORT=80 && react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"source-map-loader": "^3.0.1",
"webpack": "^5.70.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.7.4"
},
"proxy": "http://54.80.46.251:5000/"
}
如果你知道这个问题的解决方法,请帮我。谢谢
我在开发环境中通过将DANGEROUSLY_DISABLE_HOST_CHECK=true
添加到.env
文件解决了这个问题。
你可能想看看这个GitHub问题。https://github.com/gitpod-io/gitpod/issues/628
我通过下面的链接解决了这个问题https://create-react-app.dev/docs/proxying-api-requests-in-development/感谢