首页 > 解决方案 > Flutter Insecure HTTP is not allowed by platform Error

问题描述

我正在尝试发出一个 http 发布请求,以将用户从在真实设备上运行的颤振应用程序中拯救出来。我在设置了 nginx 的 ubuntu 服务器上运行 Springboot RESTful API。可以发送邮递员请求。我已经尝试android:usesCleartextTraffic="true"在我的 android 清单中添加到我的应用程序标记,并且我尝试添加一个network_security_config并将其添加到我的应用程序标记以及应用程序标记内的元数据标记。

这是我的 network_security_config 文件:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
</network-security-config>

这是我调用 api 的颤振应用程序的代码:

这是我调用 api 的颤振应用程序的代码:

这是我的 Springboot RESTful API 代码:

这是我的 Springboot RESTful API 代码

标签: javaflutterubuntu

解决方案


I have figured out my issue! The issue was that I was adding android:usesCleartextTraffic="true" in the wrong android manifest file. Previously I had it under android/app/src/profile/AndroidManifest.xml but the proper spot is under andoird/app/src/debug/AndroidManifest.xml. As stated in https://flutter.dev/docs/release/breaking-changes/network-policy-ios-android


推荐阅读