- Building RESTful Web services with Go
- Naren Yellavula
- 156字
- 2021-07-02 20:14:02
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:
- foo.com requests the OPTIONS method on bar.com.
- bar.com sends a header like Access-Control-Allow-Origin: http://foo.com in response to the client.
- 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:
推薦閱讀
- RCNP實驗指南:構(gòu)建高級的路由互聯(lián)網(wǎng)絡(luò)(BARI)
- Application Development with Qt Creator(Second Edition)
- 物聯(lián)網(wǎng)工程規(guī)劃技術(shù)
- EDA技術(shù)與VHDL編程
- 智能網(wǎng)聯(lián)汽車V2X與智能網(wǎng)聯(lián)設(shè)施I2X
- 社交電商運營策略、技巧與實操
- TCP/IP入門經(jīng)典(第5版)
- 計算機網(wǎng)絡(luò)與通信(第2版)
- 物聯(lián)網(wǎng)通信技術(shù)
- 圖解手機元器件維修技巧
- CCNP TSHOOT(642-832)認(rèn)證考試指南
- Kong網(wǎng)關(guān):入門、實戰(zhàn)與進階
- 新手易學(xué):新手學(xué)淘寶開店
- 異構(gòu)蜂窩網(wǎng)絡(luò)關(guān)鍵理論與技術(shù)
- 互聯(lián)網(wǎng)安全的40個智慧洞見(2016)