mirror of
https://github.com/txtdot/txtdot
synced 2024-10-18 14:40:19 +03:00
SECURITY BUGFIX: "false" env var value was parsed as true
This commit is contained in:
parent
3a8198ea14
commit
a8d4b3a2d3
@ -12,8 +12,19 @@ export class ConfigService {
|
||||
this.host = process.env.HOST || "0.0.0.0";
|
||||
this.port = Number(process.env.PORT) || 8080;
|
||||
|
||||
this.reverse_proxy = Boolean(process.env.REVERSE_PROXY) || false;
|
||||
this.reverse_proxy = this.parseBool(process.env.REVERSE_PROXY, false);
|
||||
|
||||
this.proxy_res = Boolean(process.env.PROXY_RES) || true;
|
||||
this.proxy_res = this.parseBool(process.env.PROXY_RES, true);
|
||||
}
|
||||
|
||||
parseBool(value: string | undefined, def: boolean): boolean {
|
||||
if (!value) return def;
|
||||
switch (value) {
|
||||
case "false":
|
||||
case "0":
|
||||
return false;
|
||||
default:
|
||||
return Boolean(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user