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

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:

 

主站蜘蛛池模板: 驻马店市| 新乡县| 威海市| 迁西县| 武定县| 慈溪市| 万山特区| 靖西县| 抚顺县| 靖西县| 平潭县| 龙门县| 张北县| 孙吴县| 调兵山市| 普格县| 清新县| 承德市| 奉节县| 二手房| 淮南市| 江油市| 华池县| 通州区| 江津市| 丽江市| 芜湖市| 宜丰县| 梨树县| 晋中市| 三河市| 五大连池市| 斗六市| 新建县| 南郑县| 襄汾县| 万宁市| 清水河县| 营山县| 天峨县| 措勤县|