官术网_书友最值得收藏!

Cross-Origin Resource Sharing (CORS)

The most important application of this OPTIONS method is Cross-Origin Resource Sharing (CORS). Initially, browser security prevented the client from making cross-origin requests. It means a site loaded with the URL www.foo.com can only make API calls to that host. If the client code needs to request files or data from www.bar.com, then the second server, bar.com, should have a mechanism to recognize foo.com to get its resources.

This process explains the CORS:

  1. foo.com requests the OPTIONS method on bar.com.
  2. bar.com sends a header like Access-Control-Allow-Origin: http://foo.com in response to the client.
  3. Next, foo.com can access the resources on bar.com without any restrictions that call any REST method.

If bar.com feels like supplying resources to any host after one initial request, it can set Access control to * (that is, any).

The following is the diagram depicting the process happening one after the other:

 

主站蜘蛛池模板: 康定县| 鹿邑县| 云阳县| 确山县| 曲周县| 泸州市| 黑山县| 乳山市| 昂仁县| 临安市| 景德镇市| 贺兰县| 依安县| 遂平县| 同心县| 沽源县| 乐亭县| 桐乡市| 泉州市| 西乌珠穆沁旗| 乌拉特前旗| 驻马店市| 读书| 新龙县| 华池县| 永修县| 东宁县| 洛浦县| 宽甸| 钦州市| 宁都县| 马龙县| 盱眙县| 城市| 黔东| 郴州市| 英超| 鄂州市| 锡林浩特市| 彭山县| 民乐县|