fixed: 防止Config.ssl不存在
This commit is contained in:
parent
5834a4167b
commit
c432743461
@ -25,7 +25,7 @@ if (typeof(Config.ssl)==='string') {
|
|||||||
const express = require('express')
|
const express = require('express')
|
||||||
const server = express()
|
const server = express()
|
||||||
const webToken = require('so.base/Webtoken')
|
const webToken = require('so.base/Webtoken')
|
||||||
const greenlock = Config.sslType==='greenlock'
|
const greenlock = (Config.ssl && Config.ssl.type==='greenlock')
|
||||||
? require('greenlock-express').create(Object.assign(Config.ssl.greenlockOptions, {app: server}))
|
? require('greenlock-express').create(Object.assign(Config.ssl.greenlockOptions, {app: server}))
|
||||||
: null
|
: null
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ if (typeof(Config.ssl)==='string') {
|
|||||||
else console.log(`[${new Date().toJSON()}] Server listening on ${Config.protocol}://${Config.host}:${portHttp} with IPv4=${ipv4} for ${server.settings.env} environment`)
|
else console.log(`[${new Date().toJSON()}] Server listening on ${Config.protocol}://${Config.host}:${portHttp} with IPv4=${ipv4} for ${server.settings.env} environment`)
|
||||||
})
|
})
|
||||||
} else if ('https' === Config.protocol) {
|
} else if ('https' === Config.protocol) {
|
||||||
webServer = require('https').createServer(Config.sslType === 'greenlock' ? greenlock.httpsOptions : {
|
webServer = require('https').createServer(Config.ssl.type === 'greenlock' ? greenlock.httpsOptions : {
|
||||||
key: fs.readFileSync(Config.ssl.file.key),
|
key: fs.readFileSync(Config.ssl.file.key),
|
||||||
cert: fs.readFileSync(Config.ssl.file.cert),
|
cert: fs.readFileSync(Config.ssl.file.cert),
|
||||||
// ca: [ fs.readFileSync(Config.ssl.file.ca) ] // only for self-signed certificate: https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener
|
// ca: [ fs.readFileSync(Config.ssl.file.ca) ] // only for self-signed certificate: https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener
|
||||||
@ -96,7 +96,7 @@ if (typeof(Config.ssl)==='string') {
|
|||||||
})
|
})
|
||||||
} else if ('httpall' === Config.protocol) {
|
} else if ('httpall' === Config.protocol) {
|
||||||
portHttp = 80
|
portHttp = 80
|
||||||
if (Config.sslType === 'greenlock') {
|
if (Config.ssl.type === 'greenlock') {
|
||||||
webServer = greenlock.listen(portHttp, portHttps, function (err) {
|
webServer = greenlock.listen(portHttp, portHttps, function (err) {
|
||||||
if (err) console.log(err)
|
if (err) console.log(err)
|
||||||
else console.log(`[${new Date().toJSON()}] Server listening on [${Config.protocol}] http=>https://${Config.host}:${portHttp}=>${portHttps} with IPv4=${ipv4} for ${server.settings.env} environment`)
|
else console.log(`[${new Date().toJSON()}] Server listening on [${Config.protocol}] http=>https://${Config.host}:${portHttp}=>${portHttps} with IPv4=${ipv4} for ${server.settings.env} environment`)
|
||||||
|
Loading…
Reference in New Issue
Block a user