# Response: CORS error: No 'Access-Control-Allow-Origin' header is present

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

## Root Cause

CORS middleware not added to FastAPI app or misconfigured, causing browser to block cross-origin requests.

## 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=["*"],
)
   ```
2. **** (90% success)
   ```
   For credentialed requests: allow_origins=["https://example.com"], allow_credentials=True
   ```

## Dead Ends

- **** — Duplicated code and easy to miss; middleware is the standard way. (60% fail)
- **** — Browsers reject wildcard with credentials; must specify exact origins. (80% fail)
