Adding a custom header to HTTP request using angular.js

前端 未结 8 1855
说谎
说谎 2020-11-27 13:01

I am a novice to angular.js, and I am trying to add some headers to a request:

   var config = {headers: {
            \'Authorization\': \'Basic d2VudHdvcnR         


        
8条回答
  •  旧时难觅i
    2020-11-27 13:25

    What you see for OPTIONS request is fine. Authorisation headers are not exposed in it.

    But in order for basic auth to work you need to add: withCredentials = true; to your var config.

    From the AngularJS $http documentation:

    withCredentials - {boolean} - whether to to set the withCredentials flag on the XHR object. See requests with credentials for more information.

提交回复
热议问题