Skip to content

Commit

Permalink
Transition of terminology for ENV
Browse files Browse the repository at this point in the history
RE: comments on [Issue Rob--W#320][1]

Make a path to move to more progressive terminology.

[1]: https://github.com/Rob--W/cors-anywhere/issues/320#issuecomment-801445034
  • Loading branch information
Lewiscowles1986 committed Mar 23, 2021
1 parent 11ed471 commit fb3447d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/cors-anywhere.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
4 changes: 4 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand All @@ -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: [
Expand Down

0 comments on commit fb3447d

Please sign in to comment.