Same-Origin Policy
noun
say it: “SAYM OR-ih-jin PAH-luh-see” /seɪm ˈɔrɪdʒɪn ˈpɑləsi/
The browser's safety rule that a web page may read responses only from the same scheme, host and port it came from, unless that other server allows it.
What is the same-origin policy?
The same-origin policy is the browser's rule that a page may read answers only from its own origin: the same scheme, host and port. An API on another origin has to allow the page with CORS headers, or the browser hides its answer.
Page: http://localhost:5173
API: http://localhost:3000 (another port, so another origin)
Error: blocked by CORS policy: No 'Access-Control-Allow-Origin' header
In a sentence
- “The same-origin policy stopped the page on port 5173 from reading the API's answer on port 3000.”
- “CORS doesn't switch off the same-origin policy; it's how a server names the other origins it trusts.”
Level: Journeyman · More Web Development terms at this level
Updated