# 405 Method Not Allowed on OPTIONS preflight request to /api/items

- **ID:** `python/fastapi-405-method-not-allowed-cors`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

CORSMiddleware added after router or with allow_methods not including OPTIONS; or route only allows POST.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 0.100+ | active | — | — |
| 0.110+ | active | — | — |

## Workarounds

1. **** (93% success)
   ```
   app.add_middleware(CORSMiddleware, allow_origins=['http://localhost:3000'], allow_methods=['*'], allow_headers=['*'])  # add before routes
   ```
2. **** (85% success)
   ```
   Ensure the route decorator uses @app.post('/api/items') and CORSMiddleware is registered at startup.
   ```

## Dead Ends

- **** — Fails when CORSMiddleware is not registered first. (65% fail)
- **** — Default allow_methods is ['GET']; OPTIONS still blocked. (70% fail)
