# Access to fetch at 'http://localhost:8000/api' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

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

## Root Cause

CORSMiddleware is missing or misordered; in Starlette, middleware order matters and CORSMiddleware must wrap the app.

## Version Compatibility

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

## Workarounds

1. **** (93% success)
   ```
   app.add_middleware(CORSMiddleware, allow_origins=['http://localhost:3000'], allow_methods=['*'], allow_headers=['*'])
   ```
2. **** (90% success)
   ```
   In Flask: CORS(app, resources={r'/api/*': {'origins': 'http://localhost:3000'}})
   ```

## Dead Ends

- **** — Browsers reject wildcard with credentials. (75% fail)
- **** — Preflight OPTIONS still not handled. (70% fail)
