Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Title: Mixed Content Error when launching Ionic application in Android Studio

I have developed a hybrid application using Ionic with Angular for the frontend and Spring Boot for the backend REST API. When attempting to launch my application in Android Studio, I encounter a mixed content error.

When i launch ionic everything works perfectly but when i deploy it in android i cant log in

Error: In the application console, I receive the following error:

"Mixed Content: The page at 'https://localhost/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://AdressIp:Port/doctors/login'. This request has been blocked; the content must be served over HTTPS."

I added this line on Manifest but still the same problem :

android:usesCleartextTraffic="true"

like image 468
Loran Avatar asked Jun 15 '26 12:06

Loran


2 Answers

  1. In your android/app/src/main/AndroidManifest.xml add android:usesCleartextTraffic="true".

<application 
       ...
       android:usesCleartextTraffic="true">
  1. In your capacitor.config.ts set the config as below:

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'io.ionic.starter',
  appName: 'My Capacitor App',
  webDir: 'www',
  bundledWebRuntime: false,
  android: {
    allowMixedContent: true
  }
};

export default config;
like image 125
Davide Simboli Avatar answered Jun 19 '26 13:06

Davide Simboli


if you are using capacitor, check this section "allowMixedContent" in https://capacitorjs.com/docs/config , greetings.

like image 42
Alberto C. Avatar answered Jun 19 '26 14:06

Alberto C.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!