# RuntimeError: CORS headers are missing. Use 'Access-Control-Allow-Origin' header.

- **ID:** `python/starlette-cors-missing-headers`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Starlette does not automatically add CORS headers; you must use a middleware like CORSMiddleware.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **Add CORSMiddleware to the application** (95% success)
   ```
   from starlette.middleware.cors import CORSMiddleware
app.add_middleware(CORSMiddleware, allow_origins=['*'])
   ```
2. **Use the CORSMiddleware with specific origins** (90% success)
   ```
   app.add_middleware(CORSMiddleware, allow_origins=['https://example.com'], allow_methods=['GET'])
   ```

## Dead Ends

- **Manually setting headers in each response** — Preflight OPTIONS requests are not handled. (70% fail)
- **Using a custom middleware that only adds headers on some routes** — CORS must be applied globally. (60% fail)
