mirror of
https://github.com/d0zingcat/cors-anywhere.git
synced 2026-05-13 15:09:25 +00:00
Correctly parse environment list in server.js
Previously an unset value resulted in [""] instead of [].
This commit is contained in:
10
server.js
10
server.js
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user