$http Auth Headers in AngularJS

前端 未结 8 733
闹比i
闹比i 2020-11-30 21:52

I have an angular application that is hitting a node API. Our backend developer has implemented basic auth on the API, and I need to send an auth header in my request.

8条回答
  •  伪装坚强ぢ
    2020-11-30 22:45

    In the $http doc you can see that you should set the default headers using $httpProvider:

    .config(['$httpProvider', function($httpProvider) {
        $httpProvider.defaults.headers.common['Authorization'] = 'Basic auth';
    }]);
    

提交回复
热议问题