Access-Control-Allow-Origin Header Explained

What the HTTP Access-Control-Allow-Origin header does and when it's used.

Published October 15, 2026

Access-Control-Allow-Origin tells the browser which origin may read the response in a cross-origin request. It is the core CORS header.

How it works

Use a specific origin, or * for public resources without credentials.

The Access-Control-Allow-Origin header is part of the HTTP message and is case-insensitive in name.

In a real exchange

curl -i https://example.com/
Access-Control-Allow-Origin: https://app.example.com
Where Access-Control-Allow-Origin appears.

Practical examples

The header

Access-Control-Allow-Origin: https://app.example.com

Set or use it in code

res.set('Access-Control-Allow-Origin', 'https://app.example.com')

Inspect it

curl -sI https://example.com | grep -i 'access-control-allow-origin'

Common mistakes

  • Using * with credentials
  • Reflecting arbitrary origins
  • Forgetting Vary: Origin when it varies

Key takeaways

  • Access-Control-Allow-Origin: Access-Control-Allow-Origin tells the browser which origin may read the response in a cross-origin request.
  • Check it in browser DevTools → Network.
  • Test with curl -I before deploying.

FAQ

Can I list several origins?

Not in one header; check the request Origin against a list and return that one.

Is Access-Control-Allow-Origin case sensitive?

Header names are case-insensitive; values may not be.

More HTTP articles