I have an ionic 4 application which calls a .NET Core backend api. It works correctly on chrome browser, but when I run apk on android device, the response is:
{"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":null,"ok":false,"name":"HttpErrorResponse","message":"Http failure response for (unknown url): 0 Unknown Error","error":{"isTrusted":true}}
regarding to header I appended these options:
const httpOptions = {
headers: new HttpHeaders({
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8" ,
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Origin, Content-Type, X-Auth-Token, Accept, Authorization, X-Request-With",
"Access-Control-Allow-Credentials" : "true",
"Access-Control-Allow-Methods" : "GET, POST, DELETE, PUT, OPTIONS, TRACE, PATCH, CONNECT"
})
};
I have already installed plugin: cordova-plugin-ionic-webview
and using HttpClient from "@angular/common/http"
My API hosted remotely, no ssl certificate used !
I googled all solutions, but none of them solve my problem