React-Native API calls are not working in Production- Resolved
If you are stuck with the behaviour that It is working while i run the app but after making production build API calls are not working, then you have to stop here and read this article.
First please note you are calling APIs with HTTP without HTTPS url. Android after target API 27 doesn’t allow HTTP.
There are two ways to fix this issue. First one is simple, go get some baseball bat and talk to backend developer and asked him/her to change urls from HTTP to HTTPS.
hmm it does not look safe, let me tell you second way and big news is :
Please find main AndroidManifest.xml in android folder of react-native project
project
│
└───android
│
└───app
│
│____src
|
|___main
|___ AndroidManifest.xml
Inside <application tag add this line like this
<application
android:usesCleartextTraffic=”true” >
That’s it. It looks easy but if you are reading till now, you definitely know how scary it was.
Thank you for reading. #loveCoding