平台不允许Flutter不安全的http [英] Flutter Insecure http is not allowed by platform

查看:274
本文介绍了平台不允许Flutter不安全的http的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Flutter小组最近进行了此更改,现在不允许不安全的HTTP连接. https://flutter.dev/docs/release/breaking-changes/network-policy-ios-android

Flutter team recently made this change and now insecure http connections are not allowed. https://flutter.dev/docs/release/breaking-changes/network-policy-ios-android

我想知道如何将移动设备上的flutter应用程序连接到PC上运行的本地go服务器.

I would like to know how can I connect my flutter app on mobile to local go server running on my PC.

我的服务器正在运行: http://192.168.29.45:4001 ,但未连接到该服务器

My server is running on: http://192.168.29.45:4001 but it is not connecting to it.

推荐答案

通常要求使用https链接而不是http链接.但是,可以如下所示对此进行覆盖.

Generally it is required to use https links rather than http links. However, this can be overridden as shown below.

打开 android/app/src/main 文件夹中的 AndroidManifest.xml 文件.然后将 usesCleartextTraffic 设置为 true .

Open the AndroidManifest.xml file in the android/app/src/main folder. Then set usesCleartextTraffic to true.

<application
    ...
    android:usesCleartextTraffic="true"
    ...   >

请参见此问题更多.

打开 ios/Runner 文件夹中的 Info.plist 文件.然后添加以下密钥.

Open the Info.plist file in the ios/Runner folder. Then add the following key.

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

有关更多信息,请参见此答案.

See this answer for more.

这与iOS相同.打开 macos/Runner 文件夹中的 Info.plist 文件.然后添加以下密钥.

This is the same as iOS. Open the Info.plist file in the macos/Runner folder. Then add the following key.

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

这篇关于平台不允许Flutter不安全的http的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆