如何用Express搭建一个https服务器
服务器是腾讯云的,证书已经颁发了,但express默认搭建的是http服务器,我想把他转为https,要如何操作,求教啊
3 回复
const fs = require('fs')
const express = require('express')
const privatekey = fs.readFileSync('./ca/private.key', 'utf8')
const certificate = fs.readFileSync('./ca/full_chain.pem', 'utf8')
const app = express()
const http = require('http').Server(app)
const https = require('https').Server({
key: privatekey,
cert: certificate
}, app)
分享下koa的 const app = new Koa() const options = { key: fs.readFileSync(‘xxx.key’), cert: fs.readFileSync(‘xxx.pem’) } https.createServer(options, app.callback()).listen(port)