fastapi_middleware_toolkit.cors =============================== .. py:module:: fastapi_middleware_toolkit.cors .. autoapi-nested-parse:: CORS middleware setup for FastAPI applications. Extracted from GridFlow backend/src/infrastructure/app_factory.py lines 46-59 Functions --------- .. autoapisummary:: fastapi_middleware_toolkit.cors.setup_cors_middleware Module Contents --------------- .. py:function:: setup_cors_middleware(app: fastapi.FastAPI, allowed_origins: Union[str, List[str]], allow_credentials: bool = False, allowed_methods: List[str] = None, allowed_headers: List[str] = None, max_age: int = 600) -> None Setup CORS middleware with secure defaults. Args: app: FastAPI application instance allowed_origins: List of allowed origins or single origin string allow_credentials: Whether to allow credentials (cookies, auth headers) allowed_methods: HTTP methods to allow (default: ["GET", "POST"]) allowed_headers: Headers to allow (default: standard headers) max_age: Preflight cache time in seconds (default: 600) Example: >>> from fastapi import FastAPI >>> app = FastAPI() >>> setup_cors_middleware( ... app, ... allowed_origins=["http://localhost:3000"], ... allow_credentials=False ... )