Invalid Access-Control-Allow-Origin: Lists, Paths and Duplicate Headers
By Ankit Jain · Updated
Return one valid origin or an appropriate wildcard. Diagnose duplicate headers from middleware, proxies and CDNs.
Browser message
Typical wording varies by browser:
The Access-Control-Allow-Origin header contains multiple values.
What it means
The browser cannot interpret the response as permission for one origin. This header cannot contain an origin list, a URL path, or multiple independently added values.
Evidence to inspect
Inspect raw response headers at the browser-facing edge. Look for two Access-Control-Allow-Origin lines or a combined value such as https://a.example, https://b.example. Compare the app response with the CDN response.
Smallest safe fix
Choose one layer to own CORS. Remove the second header writer. For multiple approved origins, use an exact allowlist and return only the requesting approved origin with Vary: Origin.
Example permission for an approved request (not a complete API policy):
Access-Control-Allow-Origin: https://app.example.com
Vary: Origin
The value must not be https://app.example.com/ or https://app.example.com/page. A wildcard applies only where credential inclusion is not needed. Do not trust null indiscriminately; multiple opaque origins serialize to null.
Verify the fix
Capture raw headers again after deployment. Test each approved origin, an unapproved origin, and an error response through the CDN to confirm there is exactly one valid permission value.
Use the CORS Tester to inspect public API headers or analyze a captured response. Confirm the result from the actual frontend afterward.
Continue learning
Proxy ownership and caching · Framework configuration · All errors