【问题标题】:Cant send a post request to my api with flutter无法通过颤振向我的 api 发送发布请求
【发布时间】:2021-08-11 11:35:08
【问题描述】:

我正在尝试向我的 api 发出发布请求以创建新用户。我的 api 有效,我尝试了我能找到的一切。输出为:Unhandled Exception: Bad state: Insecure HTTP is not allowed by platform: http://10.0.2.2:5000/api/register

我正在使用我尝试在我的 android 手机上使用的 android 模拟器它没有工作...

【问题讨论】:

标签: android api flutter


【解决方案1】:

如果你想允许 HTTP 请求(默认禁用),你必须在 android manifest 文件的 application 标签中添加这个代码:

<application android:usesCleartextTraffic="true"/>

对于 iOS,将 info.plist 视为源代码并添加以下代码:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

【讨论】:

  • 是的,它不起作用...我尝试了任何我在婚礼上能找到的方法都没有解决问题...
猜你喜欢
  • 2019-12-19
  • 2012-10-20
  • 2021-06-05
  • 2022-01-06
  • 2022-11-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-24
相关资源
最近更新 更多