我无法使用节点 js 将 ssl 设置到我的本地主机

I couldn't setup ssl to my localhost using node js

我安装了 OpenSSL,我创建了 cert.pem 和 key.pem,但是我无法 运行 使用 node js 和 express js 的服务器,我认为我的错误钥匙,我该如何解决这个错误,提前致谢

错误

目录名:

server.js

const express = require('express')
const app = express()
const server = require('https')
const {v4 : uuidv4} = require('uuid')
const fs = require('fs');

app.set('view engine','ejs')
app.use(express.static('public'))

const options = {
   key: fs.readFileSync('key.pem'),
   cert: fs.readFileSync('cert.pem')
};

app.get('/', (req,res) =>{
   res.redirect(`/${uuidv4()}`)

 })
 app.get('/:room' , (req,res) =>{
    res.render('meet' , {roomId : req.params.room})
 })

 server.createServer(options, (req,res) =>{
    console.log('worked')
 }).listen(3030, "192.168.1.20")

问题是因为 SSL 证书是旧的所以我找到了一个包并且它有效

https://dev.to/tingwei628/using-mkcert-in-node-js-ijm