将同一个应用程序同时作为 http 和 https

app.js

const http = require('http')
const https = require('https')
const Koa = require('koa')

const app = new Koa()

app.use(ctx => {
  ctx.body = 'Hello, World!'
})

app.listen(3000)
// http.createServer(app.callback()).listen(3000)
// https.createServer(app.callback()).listen(3000)
原文地址:https://www.cnblogs.com/aisowe/p/15250206.html