What is Same-Origin Policy?

1 min read Updated 2026-02-05

A browser security mechanism that restricts how documents or scripts from one origin can interact with resources from another origin.

Understanding Same-Origin Policy

Same-origin policy is fundamental to web security. An origin is defined by scheme (http/https), host, and port. Scripts from one origin cannot read data from another origin. CORS provides controlled exceptions to this policy.

Examples

  • JavaScript on example.com cannot read responses from api.other.com
  • Cookies are only sent to their origin domain
  • localStorage is isolated per origin

Worried about Same-Origin Policy in your app?

Our security audits identify vulnerabilities like this before attackers do. Get expert manual review of your codebase.