This is due to the CORS policy on your Node server, as both the client and server are running on different ports they are considered different "origins". CORS is a mechanism that indicates the origin that is allowed access to resources on the server. This is useful to stop unwanted requests to an API from unknown origins and more information can be found on MDN.
An option is set the CORS origin from within your server. If you're using Express, you can use middleware the set the origin:
app.use(cors({
origin: 'http://localhost:3000/'
}))
Or, if you'd rather do it manually:
app.use(() => (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();
});
It's important to note that when you deploy your application this origin will need to be updated to match the host address, be that a static IP or domain. Therefore it would be useful to set this as an environment variable.
Additionally, you can set a proxy within your React package.json like so: "proxy": "http://localhost:5000/" however this does not work in production.