I have a React web app wrapped with Capacitor and running on Android. My backend is a Node.js server running on my local machine with IP 10.0.0.193:3000.
When I open the backend in my phone’s browser, it works fine.
When the app (installed via the Play Store internal testing) makes an API request to http://10.0.0.193:3000, the request does not hit the backend.
Here's what I have tried so far:
Added
android:usesCleartextTraffic="true"inAndroidManifest.xml:<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">Confirmed that the API URL in the app is using the server IP (10.0.0.193:3000) and not localhost.
Tested that the server is reachable from the phone browser on the same network.
How can I configure a React + Capacitor Android app so that it can make HTTP requests to a backend running on my local machine over LAN? Are there special Capacitor or Android WebView settings I need to enable?
UPDATED:
I have tried:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.0.193</domain>
</domain-config>
</network-security-config>
<application
...
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config">
Still didn't work. same problem. I got this warning though:
Attribute networkSecurityConfig is only used in API level 24 and higher (current min is 23)