- Hands-On RESTful Web Services with Go
- Naren Yellavula
- 196字
- 2021-06-24 17:04:23
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 www.foo.com URL 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.
The following is the diagram depicting the CORS process:
Let's examine the steps followed in the preceding CORS diagram:
- 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 the access control to *.
In the next section, we see why the REST API plays such a major role in the next generation of web services. SPAs made it possible to leverage APIs for all purposes, including the UI, clients, and so on.
- Web交互界面設(shè)計(jì)與制作(微課版)
- Java面向?qū)ο蟪绦蜷_發(fā)及實(shí)戰(zhàn)
- Mastering C# Concurrency
- Python完全自學(xué)教程
- Oracle從入門到精通(第5版)
- OpenCV with Python By Example
- 算法精解:C語言描述
- Python Penetration Testing Essentials
- Mastering Python
- Raspberry Pi Robotic Projects
- 虛擬現(xiàn)實(shí):引領(lǐng)未來的人機(jī)交互革命
- 微服務(wù)設(shè)計(jì)
- Kotlin入門與實(shí)戰(zhàn)
- SQL Server 2008數(shù)據(jù)庫應(yīng)用技術(shù)(第2版)
- UI設(shè)計(jì)參考手冊(cè)