It may be a cross-origin error!
add this to your backend code
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "http://localhost:3000");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
and use your actual frontend address instead of http://localhost:3000
.
on top of these try removing the --public YOUR_LOCAL_IP_ADDRESS argument from your frontend's start script in package.json, since it's not necessary for running the frontend and may cause issues. You can leave the script as "start": "react-scripts start"
.
Finally, make sure that your proxy is correctly configured in your frontend's package.json file:
"proxy": "http://localhost:5000"
This tells the frontend to proxy requests to the backend running on port 5000. Make sure to restart both the frontend and backend servers after making these changes.