Back to Guides
Guide6 October 2026 · Updated 7 October 2026

What does the Access-Control-Allow-Origin header do?

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 is the Access-Control-Allow-Origin header?
  3. How does the header control access?
  4. What does `*` mean and when can it be used?
  5. What does a specific origin value mean?
  6. Why should `null` be avoided?
  7. Comparison of common values
  8. How to implement the header safely
  9. How does this relate to overall web security?
  10. Frequently asked follow - up questions
  11. TL;DR

Key takeaways

What is the Access-Control-Allow-Origin header?

The Access-Control-Allow-Origin header is a CORS response header that tells the browser whether the response may be shared with client - side code running on a given origin. It is sent by the server after receiving a cross - origin request that includes an Origin request header.

How does the header control access?

When a browser makes a cross - origin request it includes the Origin header, for example Origin: https://app.example.com. The server examines that value and decides whether to allow it. If it chooses to allow the request, it returns Access-Control-Allow-Origin with either * or the exact origin value. The browser then permits or blocks JavaScript from reading the response based on that header.

What does * mean and when can it be used?

* means any origin may read the response, but only for requests that do not include credentials (cookies, HTTP authentication, or client certificates). If a request includes credentials, the browser will reject a response that uses * and will require a specific origin value.

What does a specific origin value mean?

A specific origin value, such as Access-Control-Allow-Origin: https://example.com, restricts access to scripts that were loaded from exactly that origin. The browser will compare the request's Origin header to the value and allow the response only if they match byte - for - byte.

Why should null be avoided?

The header can also be set to null, which tells the browser to allow any origin that presents a null origin. Because a malicious page can spoof a null origin, using this value effectively opens the resource to anyone and defeats the purpose of CORS.

Comparison of common values

Header valueAllows any origin?Allows credentials?Recommended use
*YesNoPublic resources that never need cookies or auth
https://example.comNoYes (if Access-Control-Allow-Credentials: true is also set)Private APIs that serve a single trusted front - end
nullTechnically yesNoRare cases like sandboxed iframes; generally avoid

How to implement the header safely

  1. Identify which origins need to call the API or load the resource.
  2. If only one origin is required, configure the server to echo back the exact Origin header value when it matches the whitelist.
  3. Do not use * for endpoints that rely on cookies or other credentials.
  4. Avoid null unless you have a very specific sandbox use case.
  5. Test with a browser console: make a fetch request from a different origin and verify the response includes the expected header.

How does this relate to overall web security?

Access-Control-Allow-Origin is a first line of defense against cross - site data leakage. It does not replace authentication or authorization checks, but it prevents a malicious site from reading data that the browser would otherwise make available to JavaScript.

Frequently asked follow - up questions

Can I list multiple origins in a single header? No. The specification only allows a single origin value or *. To support multiple origins you must dynamically set the header based on the incoming request.

What happens if the header is missing? The browser treats the response as same - origin only, so any cross - origin script will be blocked from reading the data.

Does the header affect non - browser clients? No. Tools like curl or Postman ignore CORS headers; they are purely a browser enforcement mechanism.

TL;DR

Access-Control-Allow-Origin tells browsers which origins may read a response. Use * only for public, credential - free resources, set a specific origin for protected APIs, and avoid null to keep your data safe.

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