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}`);
  });
}
相关推荐
mounter6251 小时前
绕过主机:通过 Devmem TCP 运行 RDMA 应用
网络·网络协议·tcp/ip·rdma·devmem
2401_868534784 小时前
C语言与C++在基础语法上的区别
网络·网络协议
TlSfoward11 小时前
DLL 指纹库 采集、检索 TLSFOWARD tls指纹库
爬虫·网络协议·https·自动化
2401_8949155312 小时前
GEO 定位优化源码搭建常见报错排查:数据库、伪静态、接口调试
java·数据库·网络协议·tcp/ip·spring·unity
TBrL7UtdTELTTdut4BAL12 小时前
TL-XDR5480 WPA2/WPA3混合模式存在WPA3 SAE认证异常
网络协议
iLogIng13 小时前
基于 Boost 的静态 HTTP 服务器
http
iLogIng13 小时前
基于 Boost 的 HTTP 服务器:框架设计
http
2401_8734794013 小时前
IP地址位置精确查询的原理是怎样的?从城市级到街道级的技术拆解
网络·网络协议·tcp/ip·ip
深念Y14 小时前
老Flyme 官方 root 开启 ADB TCP 方案
linux·数据库·网络协议·tcp/ip·adb·智能手机·emmc
发光小北1 天前
PLC 私有协议采集网关如何应用?
网络协议