View difference between Paste ID: MGh6hu17 and Lvg8yyZN
SHOW: | | - or go back to the newest paste.
1
from fastapi import Request
2
import httpx
3
from app.config import settings
4
5
async def mirror_request(request: Request, body: dict = None):
6
    if not settings.ENABLE_SHADOW_REQUESTS or not settings.SHADOW_API_URL:
7
        return
8
9
    async with httpx.AsyncClient() as client:
10
        try:
11
            await client.request(
12
                method=request.method,
13
                url=f"{settings.SHADOW_API_URL}{request.url.path}",
14
                json=body,
15
                headers=request.headers
16
            )
17
        except Exception:
18
            # Log error but don't affect main request
19
            pass