# CORS error: Origin http://example.com is not allowed by Access-Control-Allow-Origin

- **ID:** `python/flask-cors-error-origin`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The CORS policy on the server does not allow the requesting origin.

## Version Compatibility

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

## Workarounds

1. **Use flask-cors to enable CORS for specific origins.** (95% success)
   ```
   from flask_cors import CORS
CORS(app, origins=['http://example.com'])
   ```
2. **Set CORS headers manually in a response.** (85% success)
   ```
   @app.after_request
def add_cors_headers(response):
    response.headers['Access-Control-Allow-Origin'] = 'http://example.com'
    return response
   ```

## Dead Ends

- **Adding a wildcard '*' to allowed origins but not handling credentials.** — Wildcard origins cannot be used with credentials in some cases. (70% fail)
- **Ignoring the error and assuming it will work on production.** — The error will persist in production if not fixed. (90% fail)
