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}`);
  });
}
相关推荐
wear工程师11 小时前
接口超时别只调大 timeout:Java HTTP 客户端其实有 3 段等待
java·http
蜡台11 小时前
本机 局域网 搭建本地 HTTPS 域名完整方案
网络协议·http·https·openssl
Alkaid207715 小时前
为什么查 IP 有两个结果?这个问题问倒过多少人
网络协议·tcp/ip
LCG元16 小时前
ESP32-IDF 远程固件升级实战:HTTPS OTA + 双分区切换 + 自动回滚
数据库·redis·https
ControlRookie17 小时前
第13篇_Client 02|TCP 连接成功,为什么 HTTP 请求还没有成功
http·codesys·plc通信·controlrookie
严谨的麻辣烫1 天前
数据中心出口与住宅出口的技术差异:从 ASN 到 TCP 行为的一次拆解
网络·网络协议·tcp/ip
2501_915921431 天前
appuploader-cli 命令行上传 IPA 到 App Store Connect upload CI 集成
android·ci/cd·小程序·https·uni-app·iphone·webview
2501_915921431 天前
抓包鹰 Traceeagle 解除证书绑定,SSL Pinning 解除
网络·网络协议·网络安全·ios·adb·https·ssl
Lucky_Turtle1 天前
【SSL】letsencrypt域名证书申请,Cloudflare域名
网络·网络协议·ssl
路由侠内网穿透1 天前
本地部署企业级快速开发平台芋道管理后台并实现外部访问
运维·服务器·网络·网络协议