Same-Origin Policy (SOP) and CORS Web Security Interview Prep HTTP 1. Same-Origin Policy (SOP) Definition: SOP is a security rule built into browsers. It stops a web page loaded from one origin from reading data from a different origin. What is an origin? The combination of protocol + domain + port . Compared to https://myapp.com : URL Same origin? Why https://myapp.com/about Yes Only the path differs http://myapp.com No Different protocol https://api.myapp.com No Different subdomain https://myapp.com:8080 No Different port Why does it exist? Imagine you are logged into mybank.com , and in another tab you open evil.com . Without SOP, JavaScript on evil.com could call mybank.com/account . Your browser would attach your bank cookies automatically, and the evil script could read your balance. SOP blocks the script from reading that response. Key interview points SOP is enforced by the browser , not the server. It restricts reading responses . The request may still ...