A simple Node.js server that can work as a proxy API, using the amazing cors-anywhere package, which initially allows us to make a request to any URL we want, adding CORS headers for us.
First clone the repository and cd into it.
cd cors-proxy
Install the application dependencies.
yarn install
Finally run the application.
yarn start
The application runs locally at http://localhost:8080
The server lets you filter CORS access to specific origins, and you should set an origin with the ORIGIN
environment variable. You can choose your preferred way of doing it, but a simple one is the following:
ORIGIN=your_origin yarn start
If you don't specify an origin, http://localhost:3000
is used by default.
You can easily deploy this proxy API with Heroku, following their instructions. Please be aware that you must specify an origin as an environment variable in this case.