nodejs 配置https 访问地址
1、下载ssl文件
xxxx.pem
xxxx.key
2、直接上示例
const express = require("express"); const compression = require('compression') const https = require('https') const fs = require('fs'); const app = express(); const options = { cert: fs.readFileSync('./目录/xxxx.pem'), key: fs.readFileSync('./目录/xxxx.key') } app.use(compression()) app.use(express.static('./dist')) var server = https.createServer(options, app) app.get("/xxx/xxx", async function (req, res) { let data=[] res.send(data); }); server.listen(8090, ()=>{ console.log('Example app listening on port 8090!') });