Recipe
CORS Design
A complete pattern for cross-origin resource sharing in Meridian APIs — preflight handling, credential modes, and wildcard restrictions.
Problem
Browsers block cross-origin requests by default. Without explicit CORS headers, your dashboard, CLI tools, and third-party integrations fail silently with opaque network errors.
Solution
Configure the Meridian API gateway to echo precise Access-Control-Allow-Origin headers. Never use * when credentials are involved — browsers reject the combination per the Fetch spec.
Preflight Flow
- Browser sends
OPTIONSwithOriginandAccess-Control-Request-Method. - Server responds with allowed methods, headers, and max age.
- Browser caches preflight for
Access-Control-Max-Ageseconds. - Actual request proceeds with credentials if
Access-Control-Allow-Credentials: trueis present.
Key Rules
- Mirror the request
Origin— never hardcode a single domain unless the API is private. - Set
Vary: Originso CDNs don't cache the wrong CORS response. - Expose custom headers via
Access-Control-Expose-Headersif the client needs to read them in JavaScript.