Problem testing app in Android Studio requesting to API in localhost

Hello, when compiling to android and testing the app it can not connect to the API mounted in localhost. It seems to be the mixed content problem since the app is mounted in a webview through https but my API is served in localhost over http. The app mounted with ionic serve and working in browser has no problems.

2023-07-03 20:30:15.481 28982-28982 Capacitor/Console ionic.soporteabptec E File: https://localhost/assets/index-7bae8f37.js - Line 232 - Msg: Mixed Content: The page at ‘https://localhost/home’ was loaded over HTTPS, but requested an insecure resource ‘http://10.0.2.2:8000/api/login’. This request has been blocked; the content must be served over HTTPS.

2023-07-03 20:30:15.541 28982-28982 Capacitor/Console ionic.soporteabptec E File: https://localhost/assets/index-7bae8f37.js - Line 232 - Msg: TypeError: Failed to fetch

So, I have looking for solutions but didnt find anything. For example this thread for the Angular version:

I am using Ionic React v7, and I expected to see something useful and easy to do quickly because I suppose a lot of devs are testing with APIs in localhost, so… any idea?

Thank you in advance.

Move your assets to ‘public/assets’ folder and then use path like ‘/assets/image.png’. Now check your app in prod mode.
I used this then both my images shown fine and api works properly.