Implementation of a basic CORS-Anywhere server is very straightforward. Simply do the following:
- Fork this repository.
- Within index.js, replace the website URLs in the
originWhitelistarray with the web address(es) that you want to authorise. You can keep the first string here as is for local testing (assuming you're using port 3000). - Navigate to the
functionsdirectory from the terminal and runnpm install. - Create a new Firebase account if you don't already have one.
- Install the Firebase CLI by running
npm install -g firebase-tools. - Log into Firebase using your Google account credentials with
firebase loginin the terminal. - From the Firebase console in your browser, create a new project. Give it a name and
project-id. - Replace the value of the
defaultfield in.firebasercwith yourproject-id. - From the bottom-left of the Firebase browser console, upgrade your billing plan from Spark (free) to Blaze (paid). Don't worry though, so long as you don't operate an open proxy or make a huge amount of requests it should be fine. You should also set up billing alerts and a cutoff just to be sure. There is a generous free tier of 2 million cloud function invocations per month in any case.
- From the terminal, navigate to the
functionsdirectory andnpm run deploy. My function deployed tohttps://proxy-ibmasyzzya-uc.a.run.app. - Prepend the API request in your application code with this URL like so. That's it, you've implemented the server!