Skip to content

Commit

Permalink
Correctly parse environment list in server.js
Browse files Browse the repository at this point in the history
Previously an unset value resulted in [""] instead of [].
  • Loading branch information
Rob--W committed May 31, 2016
1 parent 6c4234f commit efc13ee
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ var port = process.env.PORT || 8080;
// again. CORS Anywhere is open by design, and this blacklist is not used, except for countering
// immediate abuse (e.g. denial of service). If you want to block all origins except for some,
// use originWhitelist instead.
var originBlacklist = (process.env.CORSANYWHERE_BLACKLIST || '').split(',');
var originWhitelist = (process.env.CORSANYWHERE_WHITELIST || '').split(',');
var originBlacklist = parseEnvList(process.env.CORSANYWHERE_BLACKLIST);
var originWhitelist = parseEnvList(process.env.CORSANYWHERE_WHITELIST);
function parseEnvList(env) {
if (!env) {
return [];
}
return env.split(',');
}

// Set up rate-limiting to avoid abuse of the public CORS Anywhere server.
var checkRateLimit = require('./lib/rate-limit')(process.env.CORSANYWHERE_RATELIMIT);
Expand Down

0 comments on commit efc13ee

Please sign in to comment.