Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from fastapi import Request
- import httpx
- from app.config import settings
- async def mirror_request(request: Request, body: dict = None):
- if not settings.ENABLE_SHADOW_REQUESTS or not settings.SHADOW_API_URL:
- return
- async with httpx.AsyncClient() as client:
- try:
- await client.request(
- method=request.method,
- url=f"{settings.SHADOW_API_URL}{request.url.path}",
- json=body,
- headers=request.headers
- )
- except Exception:
- # Log error but don't affect main request
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement