angularjs - Restangular 1.4 setDefaultHeaders failing? -


i having trouble restangular 1.4 sending authorization headers external web api, challenges if no such header provided.

in following code try set default headers include basic auth header, when @ fiddler tells me no authorization header present start, api call rejected unauthorized.

does know if bug in restangular, or whether there lacking in way have tried code auth header?

angular.module('myapiservice', ['restangular']).factory('myapiservice', function (restangular) {   restangular.setbaseurl('http://mywebapi/api/'); var encoded = base64.encode(username + ":" + password); restangular.setdefaultheaders({ authorization: 'basic ' + encoded });  return restangular.one('users', username).get(); 

turns out issue authorization header null preflight (i.e.) options request. (to learn them, see section on preflighted requests @ [https://developer.mozilla.org/en-us/docs/web/http/access_control_cors). since able control api's basic auth handling, made api not issue 401 challenge such preflight requests. authorization header present on non-preflight requests (get,post,put,delete).


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

django - CSRF verification failed. Request aborted. CSRF cookie not set -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -