Firebase托管的Flutter Web拒绝拨打API电话
我有一个 Flutter Web 应用程序,已部署在 Firebase Hosting 上。
我有一个 Django 后端,已部署在 EC2 实例上并在 http 上运行。 我在后端启用了 CORS,尝试通过浏览器访问端点,效果很好。
但是,当我尝试使用 FlutterWeb 进行相同的调用时,它失败了。 并且出现错误类型被阻止:混合内容。 (参见下图)
我想调用这些 HTTP 端点,并且我不希望 SSL 证书混乱,因为这只是一个大学项目。我该如何解决这个问题?
我在 Flutter Web 上使用 Dio 来发出请求。什么会导致这个问题?
编辑: 我正在使用 Firebase 的 Spark 计划,显然这是一个大学项目。我是否需要升级到 blaze 计划才能启用出口流量?如果是这样,我如何确保我不会被收取高额费用?有什么建议吗? 更新:我尝试了 blaze 计划并遇到了同样的问题。
控制台说
混合内容:页面位于 “https://xxx.web.app/”是通过 HTTPS 加载的,但是 请求不安全的 XMLHttpRequest 端点 'http://xxxx.compute-1.amazonaws.com:8000/menu'。这 请求已被阻止;内容必须通过 HTTPS 提供。
有办法绕过这个吗?
I have a Flutter Web application that I have deployed on Firebase Hosting.
I have a Django backend that I have deployed on an EC2 instance and is running on http.
I have CORS enabled in the backend, tried accessing endpoints via browsers and it works just fine.
But, when I try to make the same call using FlutterWeb, it fails.
And error type of blocked:mixed content appears. (See image below)
I want to call those HTTP endpoints and I don't want an SSL certificate mess because this is just a college project. How do I fix this?
I am using Dio on Flutter Web to make requests. What would be causing this problem?
EDIT:
I am using Firebase's spark plan, obviously since it's a college project. Do I need to upgrade to the blaze plan to enable Egress traffic? If so, how do I make sure that I won't be heavily charged? Any suggestions? UPDATE: I tried the blaze plan and got the same issue.
The console says
Mixed Content: The page at
'https://xxx.web.app/' was loaded over HTTPS, but
requested an insecure XMLHttpRequest endpoint
'http://xxxx.compute-1.amazonaws.com:8000/menu'. This
request has been blocked; the content must be served over HTTPS.
Any way to bypass this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论