简体   繁体   English

由于 HTTPS 和 HTTP 无法将 FE 连接到 BE

[英]Can not connect FE to BE due to HTTPS and HTTP

I am deploying my app to cloud using Amazon services.我正在使用亚马逊服务将我的应用程序部署到云中。 I successfully deployed Back-end (NodeJS Express + MongoDB) with AWS EC2 at http://18.170.213.96:8080/ and Frontend (ReactJS) with AWS Amplify at https://master.d1p21clff7pjln.amplifyapp.com/ .我在http://18.170.213.96:8080/成功部署了后端(NodeJS Express + MongoDB)和https://master.d1p21clff7pjln.amplifyapp.com/ AWS Amplify 前端(ReactJS)。 But I can not login to my app because this error:但是我无法登录我的应用程序,因为这个错误: 在此处输入图像描述

It seems that my FE server is HTTPS while my BE server is HTTP. This is my Instance in AWS EC2看来我的FE服务器是HTTPS,而我的BE服务器是HTTP。这是我在AWS EC2中的实例在此处输入图像描述

I want to ask how to convert BE server to HTTPS or FE server to HTTP or any ways that help me solve this problem.我想问一下如何将BE服务器转换为HTTPS或将FE服务器转换为HTTP或任何可以帮助我解决此问题的方法。 This is the first time I try to deploy and I am stucked now.这是我第一次尝试部署,现在我被卡住了。 Thank you very much!非常感谢你!

You have a few options to set up HTTPS for the backend.您有几个选项可以为后端设置 HTTPS。

  • Purchase a domain, and set up a SSL certificate on your EC2 instance with letsencrypt.org for free.购买一个域,并使用 letsencrypt.org 免费在您的 EC2 实例上设置一个 SSL 证书。 Keep in mind that if the instance gets replaced or you need to add more, you will need to set it up each time.请记住,如果实例被替换或您需要添加更多实例,则每次都需要进行设置。
  • Purchase a domain, set up an ALB in front of your EC2 instance(s), and configure your certificate to the ALB.购买一个域,在您的 EC2 实例前设置一个 ALB,并将您的证书配置到 ALB。
  • Set up an AWS API Gateway of REST API type, and configure as a proxy or directly configure the paths for your API and integrate to your EC2 URL. API Gateway supports SSL out of the box without having to set your own domain (you can if you want to). Set up an AWS API Gateway of REST API type, and configure as a proxy or directly configure the paths for your API and integrate to your EC2 URL. API Gateway supports SSL out of the box without having to set your own domain (you can if你想要)。 You will probably have to configure CORS options as well to allow communication between different domains.您可能还必须配置 CORS 选项以允许不同域之间的通信。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM