How to use cors-anywhere - 10 common examples

To help you get started, we’ve selected a few cors-anywhere examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kubeless / kubeless-ui / bin / server.js View on Github external
const config = require('../config/project.config')
const server = require('../server/main')
const debug = require('debug')('app:bin:server')
const corsProxy = require('cors-anywhere')

if (config.env === 'development') {
  corsProxy.createServer({
    // originWhitelist: [], // Allow all origins
    // requireHeader: [],
    // setHeaders: { },
    // removeHeaders: []
  }).listen(config.cors_proxy_port, config.server_host, () => {
    debug(`\n\n ⚠️ CORS proxy running on ${config.server_host}:${config.cors_proxy_port}`)
  })
}

server.listen(config.server_port, () => {
  debug(`\n\n 💻  Server is now running at ${config.server_host}:${config.server_port}.`)
})
github ccxt / ccxt / examples / js / cors-proxy.js View on Github external
// JavaScript CORS Proxy
// Save this in a file like cors.js and run with `node cors [port]`
// It will listen for your requests on the port you pass in command line or port 8080 by default
let port = (process.argv.length > 2) ? parseInt (process.argv[2]) : 4080 // default
require ('cors-anywhere').createServer ().listen (port, 'localhost')
github RychardHunt / hodl-invest / client / app / src / cors.js View on Github external
let port = (process.argv.length > 2) ? parseInt (process.argv[2]) : 8080; // default
require ('cors-anywhere').createServer ().listen (port, 'localhost')
github koljakutschera / yafbp / gulpfile.js View on Github external
gulp.task('connect', function() {

	var httpProxyOptions = {};

	if(config.proxyAuth && config.proxyAuth.length > 0){

		httpProxyOptions.auth = config.proxyAuth;
	}
	
	corsAnywhere.createServer({
		originWhitelist: [],
		httpProxyOptions : httpProxyOptions
	}).listen(config.proxy_port, 'localhost', function() {
		console.log('Running CORS Anywhere on ' + 'localhost' + ':' + config.proxy_port);
	});
	
	connect.server({
		root: config.build_dir,
		livereload: true,
		port: config.connect_port
	});
});
github blockstack / blockstack-browser / gulp / tasks / proxy.js View on Github external
gulp.task('proxy', function() {
	var host = '0.0.0.0';
	var port = 1337;
	cors_proxy.createServer().listen(port, host, function() {
	    console.log('Running CORS Proxy on ' + host + ':' + port);
	});
})
github cdapio / coopr / coopr-ngui / server.js View on Github external
httpServer.listen(COOPR_UI_PORT, null, null, function () {
        console.info(httpLabel + ' listening on port %s', COOPR_UI_PORT);
    });
}

if (COOPR_SSL) {
    httpsServer.listen(COOPR_UI_SSL_PORT, null, null, function () {
        console.info(httpLabel + ' listening on port %s', COOPR_UI_SSL_PORT);
        sslStarted = true;
    });
}

/**
 * CORS proxy
 */
corsAnywhere.createServer({
    requireHeader: ['x-requested-with'],
    removeHeaders: ['cookie', 'cookie2']
})
    .on('request', function (req, res) {
        corsLogger(req, res, function noop() {
        });
    })
    .listen(COOPR_CORS_PORT, '0.0.0.0', function () {
        console.info(corsLabel + ' listening on port %s', COOPR_CORS_PORT);
    });
github cdapio / coopr / coopr-ui / server.js View on Github external
cert: fs.readFileSync(COOPR_UI_CERT_FILE, 'utf-8')
    }, app);
}
else {
    server = http.createServer(app);
}

server.listen(COOPR_UI_PORT, null, null, function () {
    console.info(httpLabel + ' listening on port %s', COOPR_UI_PORT);
});


/**
 * CORS proxy
 */
corsAnywhere.createServer({
    requireHeader: ['x-requested-with'],
    removeHeaders: ['cookie', 'cookie2']
})
    .on('request', function (req, res) {
        corsLogger(req, res, function noop() {});
    })
    .listen(COOPR_CORS_PORT, '0.0.0.0', function () {
        console.info(corsLabel + ' listening on port %s', COOPR_CORS_PORT);
    });
github cdapio / coopr / ngui / server.js View on Github external
COOPR_CORS_PORT: COOPR_CORS_PORT,
          authorization: req.headers.authorization

        }));
      }
    ]
  })
  .listen(COOPR_UI_PORT, '0.0.0.0', function () {
    console.log(httpLabel+' listening on port %s', COOPR_UI_PORT);
  });


/**
 * CORS proxy
 */
require('cors-anywhere')
  .createServer({
    requireHeader: ['x-requested-with'],
    removeHeaders: ['cookie', 'cookie2']
  })
  .on('request', function (req, res) {
    corsLogger(req, res, function noop() {} );
  })
  .listen(COOPR_CORS_PORT, '0.0.0.0', function() {
    console.log(corsLabel+' listening on port %s', COOPR_CORS_PORT);
  });
github xyfir / illuminsight / server.js View on Github external
res.header('Access-Control-Allow-Credentials', 'true');
    next();
  });
}
app.use('/sw.js', (req, res) =>
  res.sendFile(path.resolve(__dirname, 'dist', 'sw.js'))
);
app.use('/static', Express.static(path.resolve(__dirname, 'dist')));
app.get('/*', (req, res) =>
  res.sendFile(path.resolve(__dirname, 'dist', 'index.html'))
);
app.listen(process.enve.SERVER_PORT, () =>
  console.log('Listening on', process.enve.SERVER_PORT)
);

proxy
  .createServer({
    originWhitelist: [process.enve.WEB_URL],
    requireHeader: ['origin', 'x-requested-with']
  })
  .listen(process.enve.PROXY_PORT, '127.0.0.1');
github blockstack / blockstack-browser / corsproxy / corsproxy.js View on Github external
var cors_proxy = require('cors-anywhere');
var host = process.argv[4] || 'localhost';
var port = 1337;
cors_proxy.createServer().listen(port, host, function() {
	console.log('Running CORS Proxy on ' + host + ':' + port);
});

cors-anywhere

CORS Anywhere is a reverse proxy which adds CORS headers to the proxied request. Request URL is taken from the path

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis

Popular cors-anywhere functions