When i run in a android device return Response with status: 0 for URL: null

Hi guys, i’m new in Ionic 2,

When i deploy the ionic app in android device by “ionic run android”, the post request return status: 0 for URL: null .

I don’t think that problem is with cors because i put “Access-Control-Allow-Origin *” in my backend (Node JS).

When i run with ionic serve works successfully (to work in chrome i add a plugin “Allow-Control-Allow-Origin: *”);

in index.html i add:

<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">

/*Auth Service TS */
let params = “cliente=”+JSON.stringify(credentials)

let result= this.http.post(this.httpUtil.url(this.createClienteURL),params,this.httpUtil.headers())

/* Http Utils TS */

headers() {
		let headersParams = { 'Content-Type': 'application/x-www-form-urlencoded' };

		if (localStorage['token']) {
			headersParams['Authorization'] = localStorage['token'];
		let headers = new Headers(headersParams);
    	let options = new RequestOptions({ headers: headers });
    	return options;

	extrairDados(response: Response) {
    let data = response.json();
    return data || {};

  processarErros(erro: any) {
    console.log("error w : "+ erro);
	  return Observable.throw('Erro acessando servidor remoto.');

Does it request the right URI?
Anything else in the console?

Hi Guys,
I found the problem, the problems is because the cors in Node JS.

is necessary put the “Access-Control-Allow-Origin *” in return router.


router.post('/', function(req, res){

        //**** HERE THE CODE ***//
         res.setHeader('Access-Control-Allow-Origin', '*');
         res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type');

	var email 			= req.body.email;
	var senha 			= req.body.senha;
	var tipo_usuario 	= req.body.tipo_usuario;
	//var login 			= req.body.login;
	var system 			= req.body.system;
	var device_token 	= req.body.device_token;

	authentication(req, res, email, senha,  system, device_token, tipo_usuario, function(user){
		if(user !== undefined){
			var token = jwt.sign(user, config.secret);
			res.status(200).send({status: 1,token:token, 'user':user});
			res.status(200).send({status: 2, mensagem: "Login ou Senha incorretos."});
1 Like