Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Http failure response for (unknown url): 0 Unknown Error on android

I have an ionic app that when I run that on iOS then it works perfectly fine but when I run that on Android I get this error

Http failure response for (unknown url): 0 Unknown Error

enter image description here

Any reason I am getting this one? I have allowed CORS on server side as it is working on iOS devices.

Any help?

EDIT

This is what I have in my app.js file

const cors = require('cors');

And then I simply use it with default options.

app.use(cors());
like image 685
null Avatar asked Aug 23 '18 14:08

null


3 Answers

If you are using localhost, change it to the IP address of the localhost. Android doesn't seems to support it where iOS do.

Try actual host name in case it didn't work too.

like image 197
Bertram Gilfoyle Avatar answered Oct 22 '22 06:10

Bertram Gilfoyle


First you dont need CORS to call API from your android device.

Second probably your server is not accepting your request. If you are using Cloud then your server must accept request from any IP. There must be a option for allow IP address, place there from 0.0.0.1 to 254.254.254.254 so that each and every user can call your API.

Third you need to allow origin from your config.xml and also in header for CROS request. Check your API header and config file.

And fourth If your service is running under http then it will also could be the problem. Secure your service by adding SSL certificate. This could fix your problem.

like image 1
ZearaeZ Avatar answered Oct 22 '22 04:10

ZearaeZ


We had experienced the same Error several times in our App. In our case it was a problem with the headers of the request and also a CORS problem on the serverside.

Are you able to reproduce this error in the browser if you emulate a android device? Then you could compare them with the headers of the iOS request.

Or you can try to log the incoming requests on the server-side to see if the requests reach the server and what headers are set.

Hope my ideas help :)

like image 1
Mattstir Avatar answered Oct 22 '22 04:10

Mattstir