Skip to content

Instantly share code, notes, and snippets.

@WeiChiaChang
Created February 13, 2020 05:06
Show Gist options
  • Save WeiChiaChang/64cbe6eea51cd3bfc0dd259a30952c6f to your computer and use it in GitHub Desktop.
Save WeiChiaChang/64cbe6eea51cd3bfc0dd259a30952c6f to your computer and use it in GitHub Desktop.
cors-anywhere
// Reference:
// https://github.com/Rob--W/cors-anywhere
// Listen on a specific host via the HOST environment variable
var host = process.env.HOST || '0.0.0.0';
// Listen on a specific port via the PORT environment variable
var port = process.env.PORT || 8081;
var 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);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment