From bb135c956d70daa24da52ba879e9d9eebc12bd6b Mon Sep 17 00:00:00 2001 From: wass Date: Sat, 13 Apr 2024 18:33:38 +0200 Subject: [PATCH] add host usage --- server/server.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/server/server.js b/server/server.js index 0c54704..d03bf72 100644 --- a/server/server.js +++ b/server/server.js @@ -34,15 +34,16 @@ app.use((req, res, next) => { res.status(404).send("Sorry can't find that!") }) - - -console.log(`listening on ${protocol}://${host}:${port}`) - + if(protocol == "https"){ - const key = readFileSync(join(__dirname, process.env.KEY_FILE),'utf8') - const cert = readFileSync(join(__dirname, process.env.CERT_FILE),'utf8') - const httpsServer = https.createServer({key,cert},app) - httpsServer.listen(port);//443 for clear url + const key = readFileSync(join(__dirname, process.env.KEY_FILE),'utf8') + const cert = readFileSync(join(__dirname, process.env.CERT_FILE),'utf8') + const httpsServer = https.createServer({key,cert},app) + httpsServer.listen(port,host,()=>{ + console.log(`listening on ${protocol}://${host}:${port}`) + }); }else{ - app.listen(port); + app.listen(port,host,()=>{ + console.log(`listening on ${protocol}://${host}:${port}`) + }); }