Http error on Android - status 0


#1

Hello guys!

I have the response status = 0 on Android device. When the app is run in browser then the Http calls works fine. (I use Http from ‘@angular/http’:wink:

I don’t think there is a CORS problem because I already changed the server configuration to :
“Access-Control-Allow-Origin” : “"
“Access-Control-Allow-Headers” : "

“Access-Control-Allow-Methods” : “*”

In config.xml I addded:
allow-navigation href=“http://localhost:8100” />
allow-navigation href=“http://192.168.100.8:8100” />
allow-navigation href=“http:///” />
allow-navigation href=“https:///” />
access origin="" />
allow-intent href="
"/>
allow-navigation href="*"/>

And finally the http post code:
let headers = new Headers(
{
‘Content-Type’: ‘application/json’,
“Access-Control-Allow-Origin” : “*”
});
let options = new RequestOptions({ headers: headers });

    this.http.post(myUrl, JSON.stringify(body), options)
      .subscribe(
        res => {
         ...
            });
          }
        },
        err => {
          console.log("Error occured:" + err);
        });

In many topics Is indicated to use native HTTP but then the Http will not work when used in browser and I really need this as the app will be also deployed as website.

Is there something else I can do? or should I implement two types of Http calls (native when app is in Android and the other one when used in browser)?

Thank you!