From 98d7bb03fd07bc9f6a42d5d3a318ab8fab82047d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 30 Jun 2026 05:48:48 +0000 Subject: [PATCH] Ollama: suivre les redirections (reverse proxy http->https) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rend le client Ollama robuste derrière un reverse proxy qui redirige (ex. domaine public en HTTPS) sur tous les appels (version, tags, show, pull, chat). Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01SVay7z3y7q2gEe54ByAE6N --- backend/app/ollama_client.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/app/ollama_client.py b/backend/app/ollama_client.py index 50426c9..0c59951 100644 --- a/backend/app/ollama_client.py +++ b/backend/app/ollama_client.py @@ -21,28 +21,28 @@ class OllamaClient: async def ping(self) -> dict: """Vérifie la connexion et renvoie la version d'Ollama.""" - async with httpx.AsyncClient(timeout=5.0) as client: + async with httpx.AsyncClient(timeout=5.0, follow_redirects=True) as client: resp = await client.get(f"{self.host}/api/version") resp.raise_for_status() return resp.json() async def list_models(self) -> list[dict]: """Liste les modèles installés localement (/api/tags).""" - async with httpx.AsyncClient(timeout=10.0) as client: + async with httpx.AsyncClient(timeout=10.0, follow_redirects=True) as client: resp = await client.get(f"{self.host}/api/tags") resp.raise_for_status() return resp.json().get("models", []) async def show(self, name: str) -> dict: """Métadonnées détaillées d'un modèle (/api/show).""" - async with httpx.AsyncClient(timeout=15.0) as client: + async with httpx.AsyncClient(timeout=15.0, follow_redirects=True) as client: resp = await client.post(f"{self.host}/api/show", json={"name": name}) resp.raise_for_status() return resp.json() async def pull_model(self, name: str) -> AsyncIterator[dict]: """Télécharge un modèle en streamant la progression (/api/pull).""" - async with httpx.AsyncClient(timeout=None) as client: + async with httpx.AsyncClient(timeout=None, follow_redirects=True) as client: async with client.stream( "POST", f"{self.host}/api/pull", json={"name": name} ) as resp: @@ -67,7 +67,7 @@ class OllamaClient: if options: payload["options"] = options - async with httpx.AsyncClient(timeout=None) as client: + async with httpx.AsyncClient(timeout=None, follow_redirects=True) as client: async with client.stream( "POST", f"{self.host}/api/chat", json=payload ) as resp: