From 559fcbf3b9b41a09ea8bd0a4818628ca707140e8 Mon Sep 17 00:00:00 2001 From: GitHappens2Me Date: Thu, 29 May 2025 19:42:49 +0200 Subject: [PATCH] fixed non-streaming responses --- .gitignore | 6 +++--- router/proxy.py | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 359006b7..51b3e357 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ wallet.sqlite3 # Development .notes -.keys.db -.wallet.sqlite3 -.models.json +.*keys.db +.*wallet.sqlite3 +.*models.json compose.override.yml diff --git a/router/proxy.py b/router/proxy.py index 91f0c0c2..6552bfb3 100644 --- a/router/proxy.py +++ b/router/proxy.py @@ -189,10 +189,17 @@ async def proxy( key, response_json, session ) response_json["cost"] = cost_data + + response_headers = dict(response.headers) + + # Remove Transfer-Encoding header to avoid conflict with Content-Length header in common nginx setups + if "transfer-encoding" in response_headers: + del response_headers["transfer-encoding"] + return Response( content=json.dumps(response_json).encode(), status_code=response.status_code, - headers=dict(response.headers), + headers=response_headers, media_type="application/json", ) except json.JSONDecodeError as e: