CORS Setup¶
Configure Cross-Origin Resource Sharing (CORS) for your API.
Basic Setup¶
Production Configuration¶
class ProductionConfig(Config):
ENABLE_CORS = True
CORS_ALLOW_ORIGINS = [
"https://yourdomain.com",
"https://app.yourdomain.com"
]
CORS_ALLOW_METHODS = ["GET", "POST", "PUT", "DELETE"]
CORS_ALLOW_HEADERS = ["Content-Type", "Authorization"]
CORS_ALLOW_CREDENTIALS = True
Options¶
ENABLE_CORS- Enable/disable CORSCORS_ALLOW_ORIGINS- Allowed originsCORS_ALLOW_METHODS- Allowed HTTP methodsCORS_ALLOW_HEADERS- Allowed headersCORS_ALLOW_CREDENTIALS- Allow credentialsCORS_MAX_AGE- Preflight cache duration
Security Note¶
Never use ["*"] for origins in production. Always specify exact domains.