Same-Origin Policy (SOP) is a critical browser security mechanism that restricts how documents or scripts from one origin can interact with resources from another origin. An origin is defined by the combination of protocol, host, and port.
URL: https://example.com:443/page.html
Origin components:
- Protocol: https
- Host: example.com
- Port: 443
Same origin examples (relative to above):
✓ https://example.com/other.html
✓ https://example.com:443/api/data
Different origin examples:
✗ http://example.com (different protocol)
✗ https://api.example.com (different host)
✗ https://example.com:8443 (different port)
document.domain - Relax SOP for subdomainspostMessage - Controlled cross-origin communication