Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -65,11 +65,18 @@ async def proxy(path: str, request: Request):
|
|
| 65 |
follow_redirects=True
|
| 66 |
)
|
| 67 |
|
| 68 |
-
# Create response with same status code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
return Response(
|
| 70 |
content=response.content,
|
| 71 |
status_code=response.status_code,
|
| 72 |
-
headers=
|
| 73 |
)
|
| 74 |
except httpx.RequestError as exc:
|
| 75 |
raise HTTPException(status_code=503, detail=f"Error forwarding request: {str(exc)}")
|
|
|
|
| 65 |
follow_redirects=True
|
| 66 |
)
|
| 67 |
|
| 68 |
+
# Create response with same status code and content, but filter headers
|
| 69 |
+
# Remove problematic headers that could cause Content-Length issues
|
| 70 |
+
response_headers = dict(response.headers)
|
| 71 |
+
# Remove content-length header to let FastAPI calculate it correctly
|
| 72 |
+
response_headers.pop("content-length", None)
|
| 73 |
+
# Also remove transfer-encoding as it can conflict with content-length
|
| 74 |
+
response_headers.pop("transfer-encoding", None)
|
| 75 |
+
|
| 76 |
return Response(
|
| 77 |
content=response.content,
|
| 78 |
status_code=response.status_code,
|
| 79 |
+
headers=response_headers,
|
| 80 |
)
|
| 81 |
except httpx.RequestError as exc:
|
| 82 |
raise HTTPException(status_code=503, detail=f"Error forwarding request: {str(exc)}")
|