Search code examples
angularjsgoogle-chromeangular-resource

Error when accessing localhost api in chrome net::ERR_INSECURE_RESPONSE


I was trying to access api running in localhost using angular $resourses, chrome console gives me error saying ERR_INSECURE_RESPONSE.

I tried disabling web security in chrome. still same error. here is the angular factory that i used. How can I bypass this error and test my app.

    ImpactPortal.factory('apiFactory', function ($resource) {
    return $resource('https://localhost:8443/mifosng-provider/api/v1/client_impact_portal', {}, {
        query: {
            method: 'GET',
            params: {},
            isArray: true
        }
    })
});

Solution

  • You must authenticate first and then send each request along with the auth token.

    I am using RestAngular so my settings might look a little different from what you are working on.

    This will go in your application config :-

    RestangularProvider.setDefaultHeaders({ 'X-Mifos-Platform-TenantId': 'default' });
    

    and something like this will go in your controller/service

    var login = Restangular.all('authentication?username=mifos&password=password').post().then(function(user) {
       console.log(user);
     }, function() {
      console.log("There was an error saving");
     });