我已经通过添加认证我的 Angular 应用程序可以在 https 上运行
ssl: true,
sslKey: key,
sslCrt: crt
给我的angular.json
我跑通过ng serve --ssl --host: 0.0.0.0
它在 https://localhost:4200 上运行良好问题是它在浏览器上抛出了这个错误:
Mixed Content: The page at '' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ''
我一直无法找到解决方案。
似乎我正在通过 http 对我的服务进行 API 调用,例如:
http://localhost/api/...
我应该在哪里 https://localhost/api/... ?
如果是这种情况,我该如何通过 nodejs、express 和 mongodb 做到这一点?
如果不是这样,那是什么?
最佳答案
使用 http 调用文件、库和其他请求,这很糟糕,当您安装 SSL 证书时,您必须使用 https 调用所有 url(文件、库和其他请求等)以使其正常工作。
关于node.js - 对 API 的 Angular HTTPS 和 HTTP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62176201/