files/en-us/web/http/reference/headers/access-control-allow-origin/index.md
The HTTP Access-Control-Allow-Origin {{Glossary("response header")}} indicates whether the response can be shared with requesting code from the given {{Glossary("origin")}}.
Access-Control-Allow-Origin: *
Access-Control-Allow-Origin: <origin>
Access-Control-Allow-Origin: null
* (wildcard)
* can be specified as a wildcard.
Attempting to use the wildcard with credentials results in an error.<origin>
null
[!NOTE] The value
nullshould not be used. It may seem safe to returnAccess-Control-Allow-Origin: "null"; however, the origin of resources that use a non-hierarchical scheme (such asdata:orfile:) and sandboxed documents is serialized asnull. Many browsers will grant such documents access to a response with anAccess-Control-Allow-Origin: nullheader, and any origin can create a hostile document with anullorigin. Therefore, thenullvalue for theAccess-Control-Allow-Originheader should be avoided.
A response that tells the browser to allow code from any origin to access a resource will include the following:
Access-Control-Allow-Origin: *
A response that tells the browser to allow requesting code from the origin https://developer.mozilla.org to access a resource will include the following:
Access-Control-Allow-Origin: https://developer.mozilla.org
Limiting the possible Access-Control-Allow-Origin values to a set of allowed origins requires code on the server side to check the value of the {{HTTPHeader("Origin")}} request header, compare that to a list of allowed origins, and then if the {{HTTPHeader("Origin")}} value is in the list, set the Access-Control-Allow-Origin value to the same value as the {{HTTPHeader("Origin")}} value.
Suppose the server sends a response with an Access-Control-Allow-Origin value with an explicit origin (rather than the * wildcard). In that case, the response should also include a {{HTTPHeader("Vary")}} response header with the value Origin — to indicate to browsers that server responses can differ based on the value of the Origin request header.
Access-Control-Allow-Origin: https://developer.mozilla.org
Vary: Origin
{{Specifications}}
{{Compat}}