Story #31 CORS Conformance · Browser Security

The API Worked in the Backend but Failed in Every Browser

"Every server-to-server test passed. Every browser request failed with a CORS error"

MetricBridge's API gateway CORS configuration didn't include a custom authorization header added in a new frontend release. Browser preflight requests were rejected while server-side tests continued passing, leaving the analytics portal completely unusable.

What happened

MetricBridge exposed REST APIs consumed by both internal backend services and a browser-based analytics portal hosted on a separate domain. Server-to-server integrations had no CORS requirements and worked correctly. Browser access depended on the API gateway’s CORS configuration.

A frontend release introduced a custom X-Client-Version header on all browser API requests. The gateway’s CORS configuration included the standard Authorization header in its Access-Control-Allow-Headers response, but X-Client-Version wasn’t listed.

When browsers sent preflight OPTIONS requests checking whether the custom header was permitted, the gateway’s preflight response omitted it. Browsers rejected the subsequent API requests.

The analytics portal became completely unusable for all browser users. Server-side API tests, monitoring scripts, and backend integrations all continued passing because none of them went through browser CORS checks. The failure was invisible to the entire test suite.

Root cause

CORS testing was treated as a frontend concern and not included in API conformance tests. The gateway configuration change required by the new header wasn’t identified as a dependency of the frontend change. No test submitted a browser-style preflight request and verified the response allowed the required headers.

The fix

The gateway CORS configuration was updated to include X-Client-Version. API conformance tests were added that sent preflight OPTIONS requests matching real browser behavior and verified that all required headers appeared in Access-Control-Allow-Headers. Frontend header changes were added to the API change review checklist.

Lesson learned

CORS configuration is part of the API contract for browser consumers. It must be tested with real preflight requests—not just verified manually in a browser after deployment. Server-side tests that bypass CORS will never catch these failures.

The API Worked in the Backend but Failed in Every Browser