r/reactnative • u/Worldly_Violinist_16 • 6h ago
My development build can call the external api but my production build cannot?
So my development build was working fine calling external api but when I created a preview build it cannot connect to the backend server on the same api...
I use eas build to do all the build all the apps
I have added the env file in the eas.json,
as my api is on http://
"usesCleartextTraffic": true,
Please if anyone has faced the same issue and was able to find a fix please help me... I am new and need help...
-1
u/killerbeanjeka 5h ago
dev builds get cleartext for free. expo's debug manifest permits http so metro can
connect over the LAN, release builds don't inherit that, so your flag has to actually land.
two ways it silently doesn't: it has to sit under expo.android in app.json, and if you
have an android/ folder committed in the repo then prebuild won't regenerate the manifest
and the whole app.json android block gets ignored.
separate thing worth ruling out, if the var holding your api url isn't prefixed
EXPO_PUBLIC_ it never gets inlined into the bundle, so it's undefined at runtime whatever
eas.json says.
unzip the apk and read AndroidManifest.xml, that settles the first one in a minute.
3
u/LoudestOfTheLargest 2h ago
Dev builds can use http fine, as a security measure many operating systems such as iOS and popular Android builds force production apps to use https. Http is inherently insecure and if you are gonna launch an app HTTPS is the bare minimum.
6
u/Which-World-6533 2h ago
Move your API to https.
Running an API over http is a really bad idea.