Search code examples
ionic-frameworkionic4capacitor

CapacitorJS, Can not connect to backend API Android using but works on web


I am build hybrid app using capacitor.js as runtime, but i can not conncect to the backend at all. the following code works in web, android device chrome browser but not on the generated app.

async  function  checkConnection2(){
tts.value = await axios.get('http://192.168.8.101:8000/api/tts');
tts.value =tts.value.data
console.log(tts.value)

};

What i have already tried I have added usesCleartextTraffic in my android manifest


Solution

  • It turns out it is not working because the web does sent CSRF token along with a post request ,but the android app didn't. Excluding my API URIs in CSRF verification solved the problem.