# Access to fetch at 'http://api.local/items' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present.

- **ID:** `python/fastapi-cors-preflight-failed`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

CORSMiddleware is missing or configured with allow_origins that don't match the browser origin, so preflight OPTIONS requests fail.

## Version Compatibility

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

## Workarounds

1. **** (93% success)
   ```
   Add middleware before app start:
app.add_middleware(CORSMiddleware, allow_origins=['http://localhost:3000'], allow_methods=['*'], allow_headers=['*'])
   ```
2. **** (88% success)
   ```
   List explicit origins when using credentials.
   ```

## Dead Ends

- **** — Browsers reject wildcard origin when credentials are included. (80% fail)
- **** — Preflight is answered before the route runs, so manual headers don't apply to OPTIONS. (70% fail)
