CORSResponse Header

Access-Control-Allow-Origin (CORS)

Tells browsers which specific origins are permitted to access resources via XMLHttpRequest or Fetch API across domains.

Recommended Production Value
Context-Dependent
https://app.example.com (Never wildcard * with credentials)

Production Server Implementation

NGINX Configuration Snippet
add_header Access-Control-Allow-Origin "https://app.example.com" always;

Directives & Syntax Breakdown

https://trusted.com

Explicitly authorizes only the trusted domain to read cross-origin API responses.

*

Wildcard allowing any public website to fetch response (safe only for truly public static assets).

Common Security Hazards & Pitfalls

  • β€’Browsers reject responses with "*" wildcard if "Access-Control-Allow-Credentials: true" is present.
  • β€’Never echo back the request "Origin" header blindly without validation.
Frequently Asked Questions

Access-Control-Allow-Origin (CORS) - Questions & Answers

Common implementation questions, browser enforcement rules, and debugging.

CORS is a browser security sandbox mechanism. Postman and cURL are terminal utilities that do not enforce the browser Same-Origin Policy.