Mixed content error: This request has been blocked; the content must be served over HTTPS

Mixed content error: This request has been blocked; the content must be served over HTTPS

我已经在 Firebase 上部署了一个 Angular 应用程序,它使用托管在 AWS Windows EC2 实例上的 Node.js API。当我尝试 运行 浏览器上的 Firebase 应用程序并尝试登录时,出现以下错误:

The page at 'https://website.web.app/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://IP-address/API'. This request has been blocked; the content must be served over HTTPS.

有没有一种方法可以将 SSL 证书加载到 AWS EC2 实例上以允许通过 HTTPS 发送 API url?

Is there a way I can load an SSL certificate onto the AWS EC2 instance to allow the APIs to be sent over an HTTPS url?

是的,有很多方法可以做到这一点。最简单的(不要与最便宜的混淆)是在您的实例前面放置一个 Application Load Balancer。此外,您还需要 自己的域 。购买域后,您可以从 AWS ACM 获得 免费 ssl。之后您可以轻松地将 ssl 证书添加到 ALB 以获得对 HTTPS 的完全支持。