修正:vhost相关代码片段里用到了 express,需要提前单独定义。

This commit is contained in:
陆柯 2019-11-24 12:48:49 +08:00
parent 4169015794
commit 8f9794afbf

View File

@ -69,7 +69,8 @@ async function init(){ /*** 设置全局对象 ***/
(async function start(){
await init()
const server = require('express')()
const express=require('express')
const server = express()
const greenlock = (wo.Config.sslType === 'greenlock') ? require('greenlock-express').create({
version: 'draft-11',
@ -95,7 +96,7 @@ async function init(){ /*** 设置全局对象 ***/
// express.static 找到了具体文件就返回找不到就next()
// 所以,如果 vhost匹配了域名且static找到了文件就结束了。如果 vhost 匹配了域名但static找不到文件就继续往下。
if (!wo.Config.vhosts) {
server.use(require('express').static(path.join(process.cwd(), wo.Config.from), {index: 'index.html'}))
server.use(express.static(path.join(process.cwd(), wo.Config.from), {index: 'index.html'}))
// server.use(require('serve-favicon')(path.join(process.cwd(), 'public', 'favicon.ico'))) // uncomment after placing your favicon in /public
}else {
let vhost = require('vhost')