SSR使用HTTPS

1.安装 npm i browser-sync

  1. 再angular.json里配置
bash 复制代码
        "serve-ssr": {
          "builder": "@nguniversal/builders:ssr-dev-server",
          "options": {
            "ssl": true,
            "sslCert": "./node_modules/browser-sync/certs/server.crt",
            "sslKey": "./node_modules/browser-sync/certs/server.key"
        },

3.server.ts 修改function run()

TypeScript 复制代码
function run(): void {
  const port = process.env['PORT'] || 4200;
  
  // https certificates
  const privateKey = fs.readFileSync('./node_modules/browser-sync/certs/server.key');
  const certificate = fs.readFileSync('./node_modules/browser-sync/certs/server.crt');
  // Start up the Node server
// Start up the Node server
let server;
if (process.argv && process.argv.includes('--ssl')) {
    server = https.createServer({ key: privateKey, cert: certificate }, app());
} else {
    server = app();
}
  server.listen(port, () => {
      console.log(`Node Express server listening on https://localhost:${port}`);
  });
}
相关推荐
Inhand陈工6 小时前
游轮WiFi覆盖方案复盘:6台5G CPE + AP实现全船高速上网
人工智能·物联网·网络协议·网络安全·信息与通信·iot
Flash.kkl7 小时前
网络层协议IP、数据链路层、NAT详解
服务器·网络·网络协议·tcp/ip
缪懿9 小时前
应用层中的TCP协议原理
网络·网络协议·tcp/ip
梦奇不是胖猫9 小时前
[ 计算机网络 | 第三章 ] 数据链路层 02 PPP
网络·网络协议·计算机网络
Ether IC Verifier10 小时前
TCP 重传机制详解
服务器·网络·网络协议·tcp/ip·php
北京耐用通信10 小时前
耐达讯自动化:专业解决MODBUS TCP转PROFIBUS协议转换难题
人工智能·物联网·网络协议·自动化·信息与通信
yqcoder11 小时前
拆解互联网:通俗易懂的网络分层模型
前端·网络·网络协议
薛定谔的猫喵喵15 小时前
【从 HTTP 到 HTTPS】Flask 多项目迁移到 Nginx 子路径完整实战
python·nginx·http·https·flask·ssl
zhz521416 小时前
Spring Boot + 腾讯 Kona 实现 TLCP 8443 国密 HTTPS 排障实录(奇安信浏览器已通)
spring boot·后端·https·国密·gmssl·kona
曾阿伦16 小时前
requests HTTP 库解析
网络·网络协议·http