| 1. |
Explain CORS (Cross-Origin Resource Sharing) and Write its Importance. |
|
Answer» CORS stands for Cross-origin resource sharing. It is basically defined as a browser MECHANISM that enables web pages from one domain to have controlled access to resources that are located at different domains (cross-domain request). In other words, it allows scripts running on a browser client to interact with and access resources from other origins. It provides and extends flexibility to the SOP (Same-Origin Policy). A same-origin policy restricts a website's ability to access resources outside its source domain. For EXAMPLE, if a JAVASCRIPT app wanted to call an API (Application Programming Interface) running on another domain, it would be blocked and prevented from doing so because of the SOP. Due to restrictions caused by the same-origin policy, CORS was introduced. When a website's CORS policy is set up poorly, it also poses the risk of cross-domain attacks. As such, it cannot prevent cross-origin attacks such as CSRF (Cross-Site Request Forgery). |
|