首页 > 解决方案 > 在 react-native expo android 中忽略 axios/fetch 调用中的 SSL 证书错误

问题描述

我刚开始使用 react-native 并试图用它构建一个 android 应用程序。我使用了 create-react-native-app 并使用了 expo 模板。但我无法从我的服务器 kepp 获取“网络错误”的数据。我的服务器目前没有有效的证书。有没有办法在我的 fetch 调用中忽略 ssl 证书错误?

标签: androidreactjsreact-nativesslexpo

解决方案


是的,只使用http而不是https,并在清单中设置以下行

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

推荐阅读