constexpress=require('express');consthttps=require('https');constfs=require('fs');constpath=require('path');// 创建 Express 应用constapp=express();// 读取证书和私钥文件constcertPath=path.join(__dirname,'./app.local+4.pem');constkeyPath=path.join(__dirname,'./app.local+4-key.pem');constoptions={key:fs.readFileSync(keyPath),cert:fs.readFileSync(certPath)};// 设置一个示例路由app.get('/',(req,res)=>{res.send('Hello, this is a secure server!');});// 创建 HTTPS 服务器consthttpsServer=https.createServer(options,app);// 启动 HTTPS 服务器constPORT=3000;// 你可以选择其他端口httpsServer.listen(PORT,()=>{console.log(`HTTPS Server is running on https://localhost:${PORT}`);});