async def _handle_white_label_cors(
    request: Request, response: Response, white_label_id: UUID, db: AsyncSession, current_user: User
) -> None:
    """Validate white label origin - CORS headers are now handled by middleware.

    Args:
        request: The request object
        response: The response object
        white_label_id: The white label ID
        db: The database session
        current_user: The current user
    """
    # Get origin from request headers
    origin = request.headers.get("origin")
    if not origin:
        return

    try:
        # Validate against the white label's allowed origins
        white_label = await crud.white_label.get(
            db=db, id=white_label_id, current_user=current_user
        )
        if not white_label or not white_label.allowed_origins:
            logger.debug(f"White label {white_label_id} not found or has no allowed origins")
            return

        # Get allowed origins from white label
        allowed_origins = [origin.strip() for origin in white_label.allowed_origins.split(",")]

        # Check if the request origin is allowed
        if origin in allowed_origins:
            # Add CORS headers to the response
            response.headers["Access-Control-Allow-Origin"] = origin
            response.headers["Access-Control-Allow-Credentials"] = "true"
            logger.debug(f"Added CORS headers for white label {white_label_id} and origin {origin}")
    except Exception as e:
        raise HTTPException(status_code=400, detail="Failed to validate white label origin.") from e
Validate white label origin - CORS headers are now handled by middleware.

    Args:
        request: The request object
        response: The response object
        white_label_id: The white label ID
        db: The database session
        current_user: The current user
    
backend/airweave/api/v1/endpoints/white_label.py