CORS and Browser-Based API Access Failures
Server-side tests pass but browser requests fail because the gateway mishandles preflight or disallows the required origin, method, or headers.
Failure explanation
A browser blocks a cross-origin API call even though the endpoint works from curl, Postman, or a server-side client. Browser security enforces CORS, including preflight OPTIONS requests for certain methods, headers, and content types. Incorrect allowed origins, methods, headers, credentials, or exposed response headers can make an otherwise healthy API unusable by a web application.
Example
A frontend at https://portal.example.test sends an Authorization header. The browser sends OPTIONS first, but the gateway’s response does not include Authorization in Access-Control-Allow-Headers. The browser never sends the actual GET request.
How to test
- Reproduce browser preflight behavior for relevant methods and headers.
- Test allowed and disallowed origins, credentials, and exposed headers.
- Check OPTIONS routing and consistency across gateway paths/environments.
- Distinguish CORS failures from backend authorization failures.
Expected behavior
CORS responses match the documented origin, method, header, and credential policy. Disallowed origins remain disallowed; wildcard and credential rules are not combined unsafely.
Runnable examples
Each example includes a broken server, a fixed server, an OpenAPI spec, and a clrsig scenario that detects the failure.