diff --git a/lib/cors-anywhere.js b/lib/cors-anywhere.js index f7a67e06..99315bd3 100644 --- a/lib/cors-anywhere.js +++ b/lib/cors-anywhere.js @@ -269,13 +269,25 @@ function getHandler(options, proxy) { corsMaxAge: 0, // If set, an Access-Control-Max-Age header with this value (in seconds) will be added. helpFile: __dirname + '/help.txt', }; - Object.keys(corsAnywhere).forEach(function(option) { if (Object.prototype.hasOwnProperty.call(options, option)) { corsAnywhere[option] = options[option]; } }); + if (Object.prototype.hasOwnProperty.call(options, 'originWhitelist')) { + if (options.originWhitelist.length && !corsAnywhere.originAllowList.length) { + console.warn("Deprecated Property used 'originWhitelist'"); + corsAnywhere.originAllowList = options.originWhitelist; + } + } + if (Object.prototype.hasOwnProperty.call(options, 'originBlacklist')) { + if (options.originBlacklist.length && !corsAnywhere.originBlockList.length) { + console.warn("Deprecated Property used 'originBlacklist'"); + corsAnywhere.originBlockList = options.originBlacklist; + } + } + // Convert corsAnywhere.requireHeader to an array of lowercase header names, or null. if (corsAnywhere.requireHeader) { if (typeof corsAnywhere.requireHeader === 'string') { diff --git a/server.js b/server.js index 7aa0d5fe..e18e4f1b 100644 --- a/server.js +++ b/server.js @@ -9,6 +9,8 @@ var port = process.env.PORT || 8080; // use originAllowList instead. var originBlockList = parseEnvList(process.env.CORSANYWHERE_BLOCKLIST); var originAllowList = parseEnvList(process.env.CORSANYWHERE_ALLOWLIST); +var originBlackList = parseEnvList(process.env.CORSANYWHERE_BLACKLIST); +var originWhiteList = parseEnvList(process.env.CORSANYWHERE_WHITELIST); function parseEnvList(env) { if (!env) { return []; @@ -23,6 +25,8 @@ var cors_proxy = require('./lib/cors-anywhere'); cors_proxy.createServer({ originBlockList: originBlockList, originAllowList: originAllowList, + originBlackList: originBlackList, + originWhiteList: originWhiteList, requireHeader: ['origin', 'x-requested-with'], checkRateLimit: checkRateLimit, removeHeaders: [