Nico
Nico

Reputation: 167

React Native: API calls work locally but not from APK

I have deployed a botpress application to AWS (EC2) with Dokku, following the docs of botpress. To communicate with the bot I'm doing API calls to the IP address (52.xx.xxx.xx:3000).

This works fine when I'm running my RN app locally or when I test the API with Postmen. As soon as I release an APK I can't communicate with the API anymore, and I don't have a way to see why network requests are failing.

Since I'm not very experienced with servers, I'm assuming the problem lies somewhere in the server settings, thank you for any advice.

Upvotes: 0

Views: 306

Answers (2)

MHP
MHP

Reputation: 663

In order to view remote documents from an HTTP URL, cleartext network traffic support is required. On Android 9.0 (API level 28) or higher, cleartext support is disabled by default and apps targeting Android 9.0 or higher will need to add the android:usesClearTextTraffic="true" flag in the AndroidManifest.xml file.

If you are only working with HTTPS files, this flag is not required.

Upvotes: 1

Aexomir
Aexomir

Reputation: 176

are you using HTTP? in that case use android:usesCleartextTraffic="true" in AndroidManifest.xml

Upvotes: 1

Related Questions