Skip to content

Commit

Permalink
fix port parsing and change prioritization / order
Browse files Browse the repository at this point in the history
- only port configurations that are valid after parseInt are considered
- change prioritization from most specific config to least specific,
  meaning that args.port will take precedent over env.PORT over
  env.UPTIME_KUMA_PORT with fallback value of `3001`
  • Loading branch information
marcules committed Jan 7, 2022
1 parent 1609d37 commit cecd248
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [args.port, process.env.PORT, process.env.UPTIME_KUMA_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;
Expand Down

0 comments on commit cecd248

Please sign in to comment.