From 0a3fc7c3cd22e9e3fedfbe027b9d892c5bd85c1c Mon Sep 17 00:00:00 2001 From: Willyanto <32434607+Willyanto39@users.noreply.github.com> Date: Sun, 27 Jun 2021 16:01:37 +0000 Subject: [PATCH] fix: listening on port undefined (#19) If PORT is not defined in .env, console.log("Listening on port " + process.env.PORT) will display "Listening on port undefined". --- server.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 570bd73..c79fdd8 100644 --- a/server.js +++ b/server.js @@ -38,9 +38,11 @@ app.use(function(req, res, next) { .send('Not Found'); }); +const port = process.env.PORT || 3000; + //Start our server and tests! -app.listen(process.env.PORT || 3000, function () { - console.log("Listening on port " + process.env.PORT); +app.listen(port, function () { + console.log("Listening on port " + port); if(process.env.NODE_ENV==='test') { console.log('Running Tests...'); setTimeout(function () {