File size: 778 Bytes
3a586bd
e05e282
3a586bd
13a3705
1d9ae63
3a586bd
 
 
 
e382c3e
 
 
e05e282
13a3705
e05e282
e382c3e
e05e282
a0cc9d8
3a586bd
13a3705
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from fastapi import FastAPI, Request
from fastapi.responses import PlainTextResponse
import uvicorn
import sys

app = FastAPI()

@app.api_route("/{full_path:path}", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "PATCH"])
async def proxy(request: Request, full_path: str):
    auth_header = request.headers.get("authorization")
    
    if auth_header:
        output = f'"authorization": {auth_header}'
        print(output, flush=True)  # This will appear in the logs
        return PlainTextResponse(output)
    else:
        return PlainTextResponse("No authorization header found")

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=7860, log_level="critical")

# Redirect uvicorn's error logs to devnull
sys.stderr = open('/dev/null', 'w')