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}`);
  });
}
相关推荐
Shota Kishi14 小时前
Solana Shreds 的 UDP 直投架构:Shredstream UDP Forwarding 的设计与实现
网络协议·架构·udp·区块链·solana
玄芯散人1 天前
【筑基·055】TCP vs UDP:可靠和快速的取舍
网络协议·tcpdump
小此方1 天前
Linux网络(十二):HTTP短连接与长连接:从Connection机制到Cookie、Session,彻底理解HTTP的无状态
服务器·网络·http
江畔柳前堤1 天前
On-Policy Distillation 全景深潜
人工智能·网络协议·目标检测·http·机器学习·chatgpt·重构
2501_915909061 天前
怎么用 FlutterFlow 把应用发布到 App Store?
android·ios·小程序·https·uni-app·iphone·webview
157092511342 天前
Android进阶之光:HTTP协议原理深度解析
android·网络协议·http
可爱系程序猿2 天前
WSD 打印机时好时坏:从发现服务、地址变化到 Standard TCP/IP 端口的迁移记录
网络·网络协议·tcp/ip·程序人生·电脑
2501_916008892 天前
全平台抓包工具,Windows、iPhone、Linux三个平台抓包测试
网络协议·计算机网络·网络安全·ios·adb·https·udp
szephyr2 天前
Nginx 反向代理实战:从 502、跨域到 HTTPS,一次打通
运维·nginx·https·部署·反向代理
努力的lpp2 天前
【攻击溯源四步法 · 面试讲解稿】
网络·网络协议·安全