32 lines
856 B
Python
32 lines
856 B
Python
from __future__ import annotations
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.core.config import settings
|
|
|
|
|
|
def setup_cors(app: FastAPI) -> None:
|
|
"""Configure CORS middleware."""
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origins,
|
|
allow_credentials=settings.cors_allow_credentials,
|
|
allow_methods=["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
|
|
allow_headers=[
|
|
"Authorization",
|
|
"Content-Type",
|
|
"Accept",
|
|
"X-Request-ID",
|
|
"X-Requested-With",
|
|
],
|
|
expose_headers=[
|
|
"X-Request-ID",
|
|
"X-Process-Time",
|
|
"X-RateLimit-Limit",
|
|
"X-RateLimit-Remaining",
|
|
"X-RateLimit-Reset",
|
|
],
|
|
max_age=600,
|
|
)
|