cross-origin 'Authorization'-header with jquery.ajax()

后端 未结 1 1792
南方客
南方客 2020-11-27 15:58

I\'m trying to send a cross-origin domain and adding a custom \'Authorization\'-header. Please see the code below.

Error:

XMLHttpRequest can

相关标签:
1条回答
  • 2020-11-27 16:32

    This is an example of making a CORS request. If you have access to the server (which I assume you do since this is a request to localhost), you will need to add CORS-specific response headers. The simplest thing to do is to add the following response headers:

    Access-Control-Allow-Origin: *
    Access-Control-Allow-Methods: GET, POST, PUT, DELETE
    Access-Control-Allow-Headers: Authorization
    

    Your server also needs to be configured to respond to HTTP OPTIONS requests. You can learn more about making CORS requests here: http://www.html5rocks.com/en/tutorials/cors/

    0 讨论(0)
提交回复
热议问题