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}`);
  });
}
相关推荐
德迅云安全-上官1 小时前
源站隐身 + 流量清洗,高防 IP 品牌实力精选
网络·网络协议·tcp/ip
瓦学妹10 小时前
代理IP连接失败怎么办?2026代理IP异常排查与解决方法
网络·网络协议·tcp/ip
ITxiaobing202311 小时前
广告归因数据对齐实战:从IP溯源看点击欺诈与AppsFlyer P360的匹配度优化
大数据·网络协议·tcp/ip
Icoolkj12 小时前
ICOOLKJ 前后端分离项目完整部署文档(MySQL8.4+Redis+JDK21+Nginx+HTTPS+自动同步演示库)
redis·nginx·https
budaoweng060912 小时前
charles报错HTTP/1.1 200 Connection established
网络·网络协议·http
TlSfoward13 小时前
爬虫指纹漂移监控与回归测试:JA3/JA4 变化为什么会影响线上验证 TLSFOWARD
数据库·爬虫·网络协议·搜索引擎
IPDEEP全球代理13 小时前
住宅IP、移动IP、机房IP有什么区别?
网络·网络协议·tcp/ip
CHANG_THE_WORLD1 天前
TCP 三次握手彻底解析:SYN、ACK、SEQ、确认号与状态迁移
网络·网络协议·tcp/ip
2501_915106321 天前
TraceEagle 代理抓包教程 本机和手机的 HTTPS 抓包方法
网络协议·计算机网络·网络安全·ios·adb·https·udp
小心我捶你啊1 天前
数据采集和Web解锁不是一回事,从用途到规则区分
前端·爬虫·网络协议