0

It works fine when I use the Browser with Ionic Serve but when I try to run it on my phone with android studio I get an ERR_CONNECTION_REFUSED (when I use localhost, which makes sense) or anhttps://192.168.0.120:55275/umbraco/HbigApp/HbigAppSurface/GetBetriebeStartsWith net::ERR_SSL_PROTOCOL_ERROR (when I use my laptops IP). The port is correct, the backend is up and running. I have cleared the caches on all my Browsers, I have tried using my phones hotspot and I'm really not sure anymore what I could do. My backend is in ASP.net, frontend is Ionic 5.

Frontend:

getUrl(action: string) {
    if (isDevMode()) {
      return (
        "https://192.168.0.120:55275/umbraco/HbigApp/HbigAppSurface/" + action
      );
    }
    return (
      "https://www.hierbinichgast.de/umbraco/HbigApp/HbigAppSurface/" + action
    );
}

  getBetriebe(): Observable<any> {
    const params = new HttpParams();

    return this.http.post<any>(this.helperService.getUrl("GetBetriebeStartsWith"),
    params,
    {headers: this.headers}
    );
  }

Evil-E
  • 3
  • 3
  • Have you check by replacing Https to http like that: http://192.168.0.120:55275/umbraco/HbigApp/HbigAppSurface/ and also i think your phone and source of application will be on same network – Waleed Dec 10 '20 at 09:47
  • if I try to use http I get a CORS error – Evil-E Dec 10 '20 at 09:57
  • For CORS error have you already tried this one Using Microsoft.AspNet.WebApi.Cors To use Microsoft CORS package, you need to install from NuGet package. Go to Tools Menu-> Library Package Manager -> Package Manager Console -> execute the below command. Install-Package Microsoft.AspNet.WebApi.Cors ``` [EnableCors(origins: "http://localhost:5901/DemoApp/WebForm1.aspx", headers: "*", methods: "*")] public class ValuesController : ApiController { } ``` – Waleed Dec 10 '20 at 10:04
  • Have you checked that the URL is accessible from other devices ? – Delwyn Pinto Dec 10 '20 at 10:07
  • @DelwynPinto I have tried from my physical device and from an Android Studio emulator, both get the same error. – Evil-E Dec 10 '20 at 10:59
  • @Waleed I'll try – Evil-E Dec 10 '20 at 10:59
  • Does this answer your question? [Ionic 5/Capacitor ERR\_CLEARTEXT\_NOT\_PERMITTED in Android](https://stackoverflow.com/questions/60906953/ionic-5-capacitor-err-cleartext-not-permitted-in-android) – Najam Us Saqib Dec 10 '20 at 12:29
  • @NajamUsSaqib I tried ADDING a server url in the capacitor config since I didn't have one to begin with but that just made it that the app doesn't load at all – Evil-E Dec 10 '20 at 13:01

0 Answers0