belaczek / hodlwatch

Simple, yet powerful web app for automatic cryptocurrency portfolio tracking
https://hodl.watch
MIT License
121 stars 26 forks source link

Add a cors proxy server that can be run locally? #22

Closed cktang88 closed 3 years ago

cktang88 commented 3 years ago

I was thinking that some people want to run their own cors proxy servers for privacy reasons, so it might be easier for them if this proj includes one, and has an npm script to start it?

Then they could just do: image

Something like

/*
* from https://www.npmjs.com/package/cors-anywhere#example
*/

// Listen on a specific host via the HOST environment variable
const host = process.env.HOST || "0.0.0.0";
// Listen on a specific port via the PORT environment variable
const port = process.env.PORT || 8080;

const cors_proxy = require("cors-anywhere");
cors_proxy
  .createServer({
    originWhitelist: [], // Allow all origins
    requireHeader: ["origin", "x-requested-with"],
    removeHeaders: ["cookie", "cookie2"],
  })
  .listen(port, host, function () {
    console.log("Running CORS Anywhere on " + host + ":" + port);
  });

I can make a PR if this is something you feel is beneficial!

belaczek commented 3 years ago

Hi @cktang88, yes that makes sense 👍 I'm open to your PR