same-origin policy
The browser security rule that stops page code from reading responses from a different origin unless that origin allows it.
In more detail
It protects your logged-in sessions on one site from scripts on another. CORS is the controlled way to relax it. Command-line clients have no such policy.
Example
In the browser: Without it, any site you visit could read your email or bank pages using your cookies. Sending a cross-origin request is often allowed, but reading the response needs CORS permission from the server.Related terms
- CORS — The browser rule set that decides whether web page code from one origin may read a response from a different origin.
- origin — The scheme, host and port a web page came from, such as https://app.example, which browsers use to decide what the page may access.
- cross-site request forgery — An attack where another website makes the victim's browser send a request to your site, and the browser's cookie makes it look genuine.
Taught in
- Cookies And CORS — Modern API Architecture: REST, GraphQL & gRPC
- Same-Origin Policy, CORS Preflight, Credentials And Headers — Frontend Architecture & Web Platform
- Session Architecture: HTTP-Only Cookies vs Tokens — Production Full-Stack Engineering
- Secure Defaults — Application Security & Threat Modeling for Engineers
- Cross-Site Request Forgery — Application Security & Threat Modeling for Engineers