将同一个应用程序同时作为 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)

posted on 2021-09-10 10:12  aisowe  阅读(84)  评论(0编辑  收藏  举报

导航