From 2d6d255b24843664119a1ce841e96d781e56c942 Mon Sep 17 00:00:00 2001 From: lideming Date: Thu, 18 Feb 2021 12:29:00 +0800 Subject: [PATCH] Don't try to read TLS cert files when not using HTTPS --- src/bin/www | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bin/www b/src/bin/www index 86e4c08..837bedd 100755 --- a/src/bin/www +++ b/src/bin/www @@ -10,11 +10,6 @@ const http = require('http'); const https = require('https'); const fs = require('fs'); -const options = { - // cert: fs.readFileSync('etc/tls/fullchain.pem'), - // key: fs.readFileSync('etc/tls/privkey.pem') -} - /** * Get ports from environment and store in Express. */ @@ -50,6 +45,11 @@ if (http_all_interfaces) { app.listen(http_port, 'localhost'); } +const options = !https_port ? {} : { + cert: fs.readFileSync('etc/tls/fullchain.pem'), + key: fs.readFileSync('etc/tls/privkey.pem') +}; + const server = https.createServer(options, app); if (https_port) {