Search code examples
angularjscordovabrowsercorsconnection-refused

Cross origin request not working in Cordova with AngularJS


I am developing mobile application with Cordova tool and using angularJS.

I have written services in different project. I need to call those services in my cordova application, Whenever I try to call service it giving me Error:

net::ERR_CONNECTION_REFUSED

This might be browser issue or headers issue. Please suggest me right way to solve this issue.

Currently I am running service on localhost, and It is working perfectly when I call them from fiddler.

I have also open CORS in service project.

JodoModule.service("AccountSrv", function ($http) {
    this.signUp = function (user) {
        var SignUpReq = {
            method: 'GET',
            url: 'http://localhost:62676/api/Account/signin'
        }
        $http(SignUpReq).success(function () { alert("Succ"); }).error(function (data) { alert("Err = " + JSON.stringify(data)); });
    }
});

and my controller is,

JodoModule.controller("AccountCtrl", function ($scope, AccountSrv) {
    $scope.signUp = function () {
        AccountSrv.signUp();
    }
});

Solution

  • You can disable cross domain proxies in the emulator as a workaround.