JavaScriptMedium
Explain the same-origin policy with regards to JavaScript
By FrontendPro Editorial Team Updated 8/8/2026
#JavaScript
Answer
The same-origin policy is a security measure implemented in web browsers to prevent malicious scripts on one page from accessing data on another page. It ensures that web pages can only make requests to the same origin, where the origin is defined by the combination of the protocol, domain, and port. For example, a script from http://example.com cannot access data from http://anotherdomain.com.
