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

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:

 

主站蜘蛛池模板: 高邑县| 洛扎县| 股票| 肥乡县| 柏乡县| 灌阳县| 文登市| 岱山县| 壶关县| 确山县| 兴和县| 信阳市| 彩票| 衡东县| 沽源县| 菏泽市| 武威市| 怀宁县| 田阳县| 天峻县| 正定县| 含山县| 昌邑市| 德格县| 丰宁| 延寿县| 五寨县| 茂名市| 磐石市| 中牟县| 禹州市| 洛阳市| 曲阳县| 房山区| 遵义市| 烟台市| 凤冈县| 安陆市| 农安县| 渭南市| 胶州市|