From: Stefan Gasser Date: Tue, 20 Jan 2026 21:23:49 +0000 (+0100) Subject: Fix OpenAI wildcard proxy host header and query string forwarding (#54) X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=104b813b965d8dd5566209a295a92243e21f41f0;p=sgasser-llm-shield.git Fix OpenAI wildcard proxy host header and query string forwarding (#54) --- diff --git a/src/routes/openai.ts b/src/routes/openai.ts index b4e7b55..60fad19 100644 --- a/src/routes/openai.ts +++ b/src/routes/openai.ts @@ -147,12 +147,14 @@ openaiRoutes.all("/*", (c) => { const config = getConfig(); const { baseUrl } = getOpenAIInfo(config.providers.openai); const path = c.req.path.replace(/^\/openai\/v1/, ""); + const query = c.req.url.includes("?") ? c.req.url.slice(c.req.url.indexOf("?")) : ""; - return proxy(`${baseUrl}${path}`, { + return proxy(`${baseUrl}${path}${query}`, { ...c.req, headers: { - "Content-Type": c.req.header("Content-Type"), - Authorization: c.req.header("Authorization"), + ...c.req.header(), + "X-Forwarded-Host": c.req.header("host"), + host: undefined, }, }); });