Back to Guides
Guide5 October 2026

What is the difference between the same - origin policy and CORS?

Decloak is an AI-powered web security intelligence platform that scans a site's HTTP/TLS posture, JavaScript, and third-party scripts to produce a report anyone can read. This guide is part of Decloak's library of practical, source-backed security guidance.

In this guide
  1. Key takeaways
  2. What does the same - origin policy actually block?
  3. How does CORS allow a server to relax the same - origin policy?
  4. Who enforces the rules and where does the logic live?
  5. When are credentials like cookies or HTTP auth sent?
  6. What are the practical implications for developers?
  7. How can you verify your CORS setup quickly?
  8. Where does CORS fit into the overall web security picture?

Key takeaways

What does the same - origin policy actually block?

The same - origin policy prevents a page’s JavaScript from reading data or manipulating the DOM of any resource whose scheme, host, or port differs from the page’s own origin. In practice this means fetch(), XMLHttpRequest, and similar APIs can issue cross - origin requests, but the browser will not expose the response to the script unless an exception is granted.

How does CORS allow a server to relax the same - origin policy?

CORS works by having the server include specific HTTP response headers such as Access-Control-Allow-Origin and Access-Control-Allow-Methods. When the browser sees these headers, it knows the server has opted in to share the response with the requesting origin. For non - simple requests the browser first sends a pre - flight OPTIONS request to verify the permission.

Who enforces the rules and where does the logic live?

The browser enforces both SOP and CORS, but the decision point differs. SOP is enforced purely by the browser’s core security logic based on origin comparison. CORS adds a server - side decision point: the server must return the correct headers, and the browser then checks those headers before exposing the response.

When are credentials like cookies or HTTP auth sent?

Credentials are always included in the underlying HTTP request, regardless of SOP or CORS. However, under SOP the response is hidden from the script, so the credentials cannot be used to read data. With CORS the server can explicitly allow credentials by sending Access-Control-Allow-Credentials: true together with a concrete Access-Control-Allow-Origin value (the wildcard * is not permitted when credentials are allowed).

What are the practical implications for developers?

How can you verify your CORS setup quickly?

  1. Open the browser’s developer tools and look at the network tab for a cross - origin request.
  2. Check the response headers for Access-Control-Allow-Origin and related headers.
  3. If the request required a pre - flight, confirm that the OPTIONS response also contains the necessary headers.
  4. Use Decloak’s free scan (runs core layers including HTTP/TLS posture and static HTML analysis) to get a graded report that highlights missing or misconfigured CORS headers.

Where does CORS fit into the overall web security picture?

CORS is one of many layers that protect a web application. It complements SOP by providing a controlled way to share resources, but it does not replace other security measures such as proper authentication, TLS configuration, and secure coding practices. Decloak’s layered approach (including HTTP/TLS posture, JavaScript CVE scanning, and platform - specific checks) helps you see how CORS interacts with the rest of your security posture.

Free security scan

See what's actually exposed on your site.

Decloak's free scan runs in about 15 seconds, no account required, and covers:

  • HTTP/TLS security posture
  • JavaScript CVEs
  • Exposed Supabase/Lovable/Base44 misconfigurations
  • AI-written executive summary