I'm developing a mobile app using Angular + Ionic + Capacitor, which consumes a Node.js (Express) REST API.
Everything works perfectly when running the app in the browser on PC or mobile, but when I install the APK on my Android device, the login fails, and I get this error:
Http failure response for http://my_ip:3000/api/login: 0 Unknown Error
The Express server is running and listening on:
app.listen(3000, '0.0.0.0');
The /api/login endpoint works perfectly in a browser (returns 401 if credentials are invalid, as expected).
I can access http://my_ip:3000/api/login from the mobile browser (returns "Cannot GET", which is fine for GET request).
I added network_security_config.xml:
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">192.168.1.135</domain>
</domain-config>
</network-security-config>
My AndroidManifest.xml includes:
<application
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
... >
</application>
<uses-permission android:name="android.permission.INTERNET" />
The problem happens only from the installed APK
A GET /api/ping endpoint works fine from the APK, returning { message: "pong" }, but POST /api/login fails silently with status 0 and "Unknown Error".
adb logcat doesn’t show useful errors, only “net::ERR_FAILED” or status 0.
Any ideas or suggestions are appreciated!