node.js - 对 API 的 Angular HTTPS 和 HTTP 请求

标签 node.js angular mongodb ssl https

我已经通过添加认证我的 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/

相关文章:

Angular 12 对请求的 IE 11 支持发出警告。为什么?

arrays - 如果字段数组和参数数组相交,则过滤 MongoDb 集合

node.js - 无法在使用Typescript构建的 Node 项目中运行Nodemon(在Windows中)

仅针对特定路由的 session Cookie

angular - 模型驱动表单提交后如何清空表单? ( Angular 2)

angular - 合并两个 rxjs 流并仅在第一个为真时发出

mongodb - 在Grails 3.1.x和Mongo 5.0.x插件中使用java.util.Set域属性

mongodb - 如何使用findone从Mongodb集合返回数组

node.js - 在 Express 中的 session 中传递变量信息

javascript - 如何不在node.js 中发回对ajax post 调用的响应?