Cross-Origin Request Blocked with POST But working fine with req on Browser but on device not working
<p>I am trying to build an application using ionic. I am using this code </p>

<pre><code>  var req = 
                    {
                        method: 'POST',
                        url: API_END_POINT + "/accounts/login",
                        data: this.toparams(myobject),
                        headers: {'Content-Type': 'application/x-www-form-urlencoded'}
                    }

                    $http(req).
                    success(function(data, status, headers, config) 
                    {
                       if(data.result = 'success') {
                console.log('Success', data);
                deferred.resolve(data);
            } else {
                deferred.resolve(0);
            }
                    }).
                    error(function(data, status, headers, config) 
                    {
                        console.error('ERR');
     deferred.resolve(0);
                    });

            return deferred.promise;
</code></pre>

<p>}</p>

<p>This is working fine on browsers but not on device .. </p>

<p>Even if i tired using this method </p>

<p>var link = API_END_POINT +"/accounts/login";</p>

<pre><code>$http.post(link, {username : $scope.data.username,password:$scope.data.password}).then(function (res){
    $scope.response = res;
});
</code></pre>

<p>This gives me CORS error on browser. </p>

<p>Any idea ?</p>

<p>Thanks</p>