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

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:

 

主站蜘蛛池模板: 会东县| 淄博市| 阳泉市| 法库县| 仙居县| 乐东| 阿巴嘎旗| 宝鸡市| 封开县| 乳源| 新建县| 望谟县| 奉新县| 安多县| 怀来县| 略阳县| 鹤岗市| 新密市| 大姚县| 龙海市| 自贡市| 确山县| 鲁甸县| 承德市| 武安市| 资源县| 六盘水市| 瑞丽市| 易门县| 黑水县| 麦盖提县| 鲜城| 孟村| 延长县| 广河县| 张家口市| 惠东县| 威海市| 宿松县| 锡林郭勒盟| 北安市|