From 0053a29d103d803c22a278a861e417933241fb97 Mon Sep 17 00:00:00 2001 From: Marc Harnos Date: Fri, 7 Jan 2022 23:16:26 +0100 Subject: [PATCH] add validation to port value parsing only port configurations that are valid (not isNaN) after parseInt are considered to be used in port variable --- server/server.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/server.js b/server/server.js index 48a4c084c..6b822a3de 100644 --- a/server/server.js +++ b/server/server.js @@ -71,7 +71,9 @@ if (hostname) { console.log("Custom hostname: " + hostname); } -const port = parseInt(process.env.UPTIME_KUMA_PORT || process.env.PORT || args.port || 3001); +const port = [process.env.UPTIME_KUMA_PORT, process.env.PORT, args.port, 3001] + .map(portValue => parseInt(portValue)) + .find(portValue => !isNaN(portValue)); // SSL const sslKey = process.env.UPTIME_KUMA_SSL_KEY || process.env.SSL_KEY || args["ssl-key"] || undefined;