I am following this basic guide to set up a local dev environment with both react and node running. I am stuck after adding a "proxy": "http://localhost:4001" statement to the package.json of the react directory. It keeps saying: Proxy error: Could not proxy request /flower from localhost:51427 to http://localhost:4001.
Environment: There's no authentication involved. It is just a boilerplate node.js and create-react-app setup. The create-react-app version is 3.0.1. I am using a Mac.
I tried the following way to figure this problem out:
- I verified that the server is running correctly and localhost:4001 does provide data back.
- I checked the browser dev tool and see the error is GET http://localhost:51427/flower 500 (Internal Server Error)
- I also added a "--ignore client" in the server's package.json
- I also tried installing http-proxy-middleware per this instruction: https://create-react-app.dev/docs/proxying-api-requests-in-development/.
Here's the package json for react:
{
"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"
}
The localhost page of react is blank instead of having text. The console log also confirms no data is received.