CORS support

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/qq_34579060/article/details/89705891

CORS support (Cross-Origin Resource Sharing) is a designated W3C Cross-Origin Resource Sharing Standards, in fact, in order to solve the front end of the cross-domain requests.

Front-end solution for cross-domain requests are JSONP, but JSONP only supports GET request, which is a big drawback, and it supports multiple CORS HTTP request methods.

 If the server supports CORS, there is a response header Access-Controller-Allow-Origin field to record access to the resource domain. When the browser receives such a response header information extraction field, the value is found to contain the current page is located, know cross-domain request, for allowing the distal end cross-domain request will not be limiting.

When Delete request to an example, the current initiates a DELETE request, the request is processed through two steps.

first step:

      Client : Send a OPTIONS request   (this request to the server will be asked whether they have the resources DELETE privileges )

      Server:   the server returns a response to the server Allow header information indicating support for the requested method

Step two:

     Client : sending a DELETE request. Next, the browser will send a cross-domain DELETE request

    Server:   the server returns a response

End cross-domain requests

 

Guess you like

Origin blog.csdn.net/qq_34579060/article/details/89705891