服务器是腾讯云的,证书已经颁发了,但express默认搭建的是http服务器,我想把他转为https,要如何操作,求教啊
https://expressjs.com/en/api.html#app.listen 去看文档
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)
CNode 社区为国内最专业的 Node.js 开源技术社区,致力于 Node.js 的技术研究。
https://expressjs.com/en/api.html#app.listen
去看文档
分享下koa的 const app = new Koa() const options = { key: fs.readFileSync(‘xxx.key’), cert: fs.readFileSync(‘xxx.pem’) } https.createServer(options, app.callback()).listen(port)