Search code examples
androidprogressive-web-appscapacitor

Can`t make HTTP request on physical android device using Capacitor


I dont understand why HTTP requests fail with 404 error when i start app on physical android device, but it works correct when i`m testing my app using web browser. With requests to https there are no problems.

I`ve tried to use capacitor-http instead axios, but it doesnt help.

function getBaseUrl(): string {
  const personStore = usePersonStore();
  return personStore.selectedMedInst.baseURL;
}

export async function allDeps(): Promise<ReceptionDTO[] | undefined> {
  return (await Http.get({url: `${getBaseUrl()}/receptions`})).data



  // const url = `${getBaseUrl()}/receptions`;
  // const result = await axios.get<ReceptionDTO[]>(url);
  // return result.data;
}

export async function allSpecs(): Promise<SpecialityDTO[] | undefined> {
  const url = `${getBaseUrl()}/allspecs`;
  const result = await axios.get<SpecialityDTO[]>(url);
  return result.data;
}

And baseUrl i get from another pinia store (I use vue for my PWA). So, there is one of my base URL's:

http://46.175.215.101:8089/IMSToWebProxyNew

Solution

  • So, i found a solution. To AndroidManifest i added this one - android:usesCleartextTraffic="true" and all works fine.