CORS & allowed origins
The headless API is designed to be called directly from the browser, so it implements CORS server-side. There’s no proxy to run — the backend decides which origins may call it based on each key’s allowed origins list.
Allowed origins
Section titled “Allowed origins”Each API key has an allowed_origins list (set when you create the key):
- Empty or containing
*→ all origins allowed. - Otherwise → only the exact origins listed (trailing slashes are ignored).
https://mystore.com, https://staging.mystore.comCORS behavior
Section titled “CORS behavior”For requests under /api/headless/v1/, the backend returns:
| Header | Value |
|---|---|
Access-Control-Allow-Origin | the requesting origin (when allowed) |
Access-Control-Allow-Credentials | true |
Access-Control-Allow-Methods | GET, POST, OPTIONS |
Access-Control-Allow-Headers | Authorization, Content-Type |
Access-Control-Max-Age | 86400 |
Vary | Origin |
- Preflight (
OPTIONS) requests can’t carry theAuthorizationheader, so the backend checks whether any active key for the shop allows the origin, and responds204 No Contentwith CORS headers if so. - On a normal request, CORS headers are only set once the API key is authenticated and the origin is in that key’s allowed list.
Server-side requests
Section titled “Server-side requests”Server-to-server calls (SSR loaders, build steps, cURL) aren’t subject to CORS. Keep the key in a server-only environment variable and call the API directly.