const Koa = require('koa');
const fs = require('fs');
const https = require('https');
const enforceHttps = require('koa-sslify');
const path = require('path');
const static = require('koa-static');
const app = new Koa();
// 证书
var options = {
key: fs.readFileSync('./cert/limengzhe.work.key'),
cert: fs.readFileSync('./cert/limengzhe.work.pem')
};
// 主页静态文件
const dist = static(path.join(__dirname) + '/dist/');
app.use(dist);
app.use(async ctx => {
ctx.body = 'Hello koa'
});
https.createServer(options, app.callback()).listen(443);
网友评论