The
Access-Control-Allow-Origin is a response header that is used to indicates whether the response can be shared with requesting code from the given origin.
Syntax:
Access-Control-Allow-Origin: * | <origin> | null
Directives: Access-Control-Allow-Origin accepts there types of directives mentioned above and described below:
- *: This directive tells the browsers to allow requesting code from any origin to access the resource. Used as a wildcard.
- <origin>: This directive defines any single origin.
- null: This directive defines null that should not be used due to any origin can create a hostile document with a "null" Origin. The "null" value for the ACAO(Access-Control-Allow-Origin) header should therefore, be avoided."
Example:
To check this Access-Control-Allow-Origin in action go to Inspect
Element -> Network check the response header for Access-Control-Allow-Origin like below, Access-Control-Allow-Origin is highlighted you can see.
👁 Image
Supported browsers: The browsers compatible with
HTTP headers Access-Control-Allow-Origin are listed below:
- Google Chrome 4.0
- Internet Explorer 10.0
- Firefox 3.5
- Safari 4.0
- Opera 12.0