Getting 404 error on http request in emulator, but same request is working in webbrowers (ionic serve)

Hi,

I’m trying to do an external post to an api. When i run it with ionic serve, it’s working fine, but when i’m running it on the emulator i’m getting an 404 error. Can somebody explain why it is working in ionic serve but not in de emulator?

$http.defaults.headers.common["Accept"] = "application/json";
$http.defaults.headers.common["Content-Type"] = "application/json";
$http.defaults.headers.common["Access-Control-Allow-Origin"] = "*";


login: function() {

            var objPost = {
                "grant_type": "password",
                "client_id": "testclient",
                "client_secret": "testclient1234",
                "username": 'test',
                "password":  'test1234'
            };

// 'url' is de location of the api
                $http.post('url', objPost)
                    .success(function (data, status, headers, config) {
                        localStorageService.set('authorisationData', data);
                        $rootScope.$broadcast('event:auth-loginConfirmed', status);
                    })
                    .error(function (data, status, headers, config) {
                        $rootScope.$broadcast('event:auth-login-failed', status, data, headers, config);
                    });
            }

Were you ever able to fix this? I’m experiencing the same exact problem right now.

Thanks! That worked!

I followed

  • Install plugin WhiteList
  • Add
    < allow-navigation href="://.example.com/" />
    < allow-intent href="http://
    /" />
    < allow-intent href="https://
    /*" />
  • Restart
    But it is not working ??? I am only testing on browser.

@yuriybash can you write the steps?