Don't try to read TLS cert files when not using HTTPS

This commit is contained in:
lideming 2021-02-18 12:29:00 +08:00
parent 0b36f83b34
commit 2d6d255b24

View file

@ -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) {