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}`);
  });
}
相关推荐
SYHC_CSDN1 小时前
HDLCross:穿透 IP 核的 HDL 跨时钟域分析平台,补齐 CDC 验证短板
网络协议·tcp/ip·fpga开发
fruge6 小时前
ClipSketch AI视频转手绘故事板实战:关键帧选取、Gemini绘图与文案生成
网络·网络协议·http
Lsetea8 小时前
DNS-01 委托有 CNAME 却查不到 TXT?用 CertbotX 核对签发前和挑战中的记录
运维·https·ssl·dns·acme
蔚蓝忧郁11 小时前
使用 matter-dissector 抓包解析 Matter 协议报文
网络协议
ss27313 小时前
FastAPI WebSocket 入门:双向通信、连接管理与广播实践;一条长连接如何撑起实时应用
websocket·网络协议·fastapi
Multipath71214 小时前
包粒度智能调度・尾时延精准管控- QMP-UDP 多链路聚合
网络·网络协议·安全·udp·智能路由器
小白菜0016 小时前
python之http模块
网络·网络协议·http
奇牙coding1 天前
Grok 4.20 一直报 HTTP 401 怎么办?换了密钥还没好,可能是请求发错了入口
网络·网络协议·http·ai
极创信息1 天前
信创国产化适配流程全解:从环境矩阵到测试证明的完整路径
运维·人工智能·http·wireshark·健康医疗
用户84913717547161 天前
查交换机 24 口的字节数,我差点被一个「正确」的回包骗了
网络协议