'Cors error in localhost. How can i solve this problem?

I am running a node.js and express server on port 5000 which is connected locally to mongo db.

I then start my react server on port 3000 and s in console I get the error:

Access to XMLHttpRequest at 'http://localhost:5000/services' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

How can i solve this problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source