Adding a custom header to HTTP request using angular.js

前端 未结 8 1811
说谎
说谎 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条回答
  •  清酒与你
    2020-11-27 13:44

    And what's the answer from the server? It should reply a 204 and then really send the GET you are requesting.

    In the OPTIONS the client is checking if the server allows CORS requests. If it gives you something different than a 204 then you should configure your server to send the correct Allow-Origin headers.

    The way you are adding headers is the right way to do it.

提交回复
热议问题