# CORS error: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

- **ID:** `python/fastapi-cors-not-enabled`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

FastAPI 应用未启用 CORS 中间件，导致浏览器阻止跨域请求。

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   from fastapi.middleware.cors import CORSMiddleware
app.add_middleware(CORSMiddleware, allow_origins=['*'], allow_methods=['*'], allow_headers=['*'])
   ```

## Dead Ends

- **** — 只处理了简单请求，预检请求（OPTIONS）仍然失败，且代码繁琐。 (60% fail)
- **** — Flask-CORS 是 Flask 的扩展，不兼容 FastAPI，会导致导入错误。 (90% fail)
