我正在遵循本基本指南来设置一个本地开发环境,同时运行react和node。在react目录的package.json中添加“ proxy”:“ http://localhost:4001”语句后,我陷入了困境。它一直在说:代理错误:无法将请求/ flower从localhost:51427代理到http://localhost:4001。
环境:不涉及身份验证。这只是样板node.js和create-react-app设置。 create-react-app版本为3.0.1。我正在使用Mac。
我尝试了以下方法来解决此问题:
这是react的json包:
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-scripts": "3.2.0"
},
"scripts": {
"start": "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"
]
},
"proxy": "http://localhost:4001"
}
react的localhost页面为空白,而不是文本。控制台日志还确认未接收到任何数据。