From 71783f8852e2b9210b4a66d4bee82c9af2fc668b Mon Sep 17 00:00:00 2001 From: rcourtman Date: Mon, 15 Dec 2025 16:51:52 +0000 Subject: [PATCH] fix(ai): normalize Ollama base URL to prevent 405 errors Users sometimes enter URLs with trailing slashes or include the /api path: - http://host:11434/ -> would become http://host:11434//api/chat - http://host:11434/api -> would become http://host:11434/api/api/chat Now we strip trailing slashes and /api suffix during client initialization. Fixes #847 --- internal/ai/providers/ollama.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/ai/providers/ollama.go b/internal/ai/providers/ollama.go index 645486d..f758680 100644 --- a/internal/ai/providers/ollama.go +++ b/internal/ai/providers/ollama.go @@ -7,6 +7,7 @@ import ( "fmt" "io" "net/http" + "strings" "time" ) @@ -22,6 +23,11 @@ func NewOllamaClient(model, baseURL string) *OllamaClient { if baseURL == "" { baseURL = "http://localhost:11434" } + // Normalize the URL: strip trailing slashes and /api suffix + // Users sometimes enter http://host:11434/ or http://host:11434/api + baseURL = strings.TrimSuffix(baseURL, "/") + baseURL = strings.TrimSuffix(baseURL, "/api") + baseURL = strings.TrimSuffix(baseURL, "/") // In case it was /api/ return &OllamaClient{ model: model, baseURL: baseURL,