0.4.5 • Published 3 years ago

cors-origin v0.4.5

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Build Status Coverage Status

CORS-ORIGIN is a NodeJS proxy which adds CORS headers to the proxied request.

Example

// 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 || 8080;
// create proxy server
var cors_proxy = require("cors-origin");
cors_proxy
  .createServer({
    originWhitelist: [], // Allow all origins
    requireHeader: ["origin", "x-requested-with"],
    removeHeaders: ["cookie", "cookie2"],
  })
  .listen(port, host, function () {
    console.log("Running CORS ORIGIN on " + host + ":" + port);
  });