请求出错:不允许到本地主机的明文 HTTP 流量
There was an error with the request: Cleartext HTTP traffic to localhost not permitted
我正在使用电容器开发 ionic 4。我试图从 localhost 调用 api 但我收到此错误
There was an error with the request: Cleartext HTTP traffic to localhost not permitted
!!
自 android 9 起,他们试图推动人们使用 https API 而不是 http。
但是有办法禁用它。
简单的答案是通过修改 AndroidManifest.xml
并将 android:usesCleartextTraffic="true"
添加到 application
来允许整个应用中的 http
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
为了更精细地调整域相关方法,我建议阅读以下内容:
https://developer.android.com/training/articles/security-config#CleartextTrafficPermitted
我正在使用电容器开发 ionic 4。我试图从 localhost 调用 api 但我收到此错误
There was an error with the request: Cleartext HTTP traffic to localhost not permitted
!!
自 android 9 起,他们试图推动人们使用 https API 而不是 http。 但是有办法禁用它。
简单的答案是通过修改 AndroidManifest.xml
并将 android:usesCleartextTraffic="true"
添加到 application
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
为了更精细地调整域相关方法,我建议阅读以下内容: https://developer.android.com/training/articles/security-config#CleartextTrafficPermitted