diff --git a/src/proxy/google-ai.ts b/src/proxy/google-ai.ts index 94b245b..2a61a9b 100644 --- a/src/proxy/google-ai.ts +++ b/src/proxy/google-ai.ts @@ -105,8 +105,8 @@ function transformGoogleAIResponse( const googleAIProxy = createQueuedProxyMiddleware({ target: ({ signedRequest }) => { if (!signedRequest) throw new Error("Must sign request before proxying"); - const { protocol, hostname, path } = signedRequest; - return `${protocol}//${hostname}${path}`; + const { protocol, hostname} = signedRequest; + return `${protocol}//${hostname}`; }, mutations: [addGoogleAIKey, finalizeSignedRequest], blockingResponseHandler: googleAIBlockingResponseHandler, @@ -120,11 +120,7 @@ googleAIRouter.post( "/v1beta/models/:modelId:(generateContent|streamGenerateContent)", ipLimiter, createPreprocessorMiddleware( - { - inApi: "google-ai", - outApi: "google-ai", - service: "google-ai", - }, + { inApi: "google-ai", outApi: "google-ai", service: "google-ai" }, { beforeTransform: [maybeReassignModel], afterTransform: [setStreamFlag] } ), googleAIProxy diff --git a/src/proxy/middleware/request/proxy-middleware-factory.ts b/src/proxy/middleware/request/proxy-middleware-factory.ts index f1c6bb7..5e50c6f 100644 --- a/src/proxy/middleware/request/proxy-middleware-factory.ts +++ b/src/proxy/middleware/request/proxy-middleware-factory.ts @@ -107,23 +107,16 @@ function pinoLoggerPlugin(proxyServer: ProxyServer) { "Error occurred while proxying request to target" ); }); - proxyServer.on("proxyReq", (proxyReq, req, res) => { - const originalUrl = req.originalUrl; - const targetHost = `${proxyReq.protocol}//${proxyReq.host}`; - const targetPath = res.req.url; + proxyServer.on("proxyReq", (proxyReq, req) => { + const from = req.originalUrl; req.log.info( - { originalUrl, targetHost, targetPath }, + { from, to: `${proxyReq.protocol}//${proxyReq.host}${proxyReq.path}` }, "Sending request to upstream API..." ); }); proxyServer.on("proxyRes", (proxyRes: ProxiedResponse, req, _res) => { - const originalUrl = req.originalUrl; - const targetHost = `${proxyRes.req.protocol}//${proxyRes.req.hostname}`; - const targetPath = proxyRes.req.path; + const target = `${proxyRes.req.protocol}//${proxyRes.req.host}${proxyRes.req.path}`; const statusCode = proxyRes.statusCode; - req.log.info( - { originalUrl, targetHost, targetPath, statusCode }, - "Got response from upstream API." - ); + req.log.info({ target, statusCode }, "Got response from upstream API."); }); } diff --git a/src/shared/network.ts b/src/shared/network.ts index 9a4f142..71d4f32 100644 --- a/src/shared/network.ts +++ b/src/shared/network.ts @@ -48,6 +48,7 @@ export function getHttpAgents() { process.env.HTTP_PROXY = proxyUrl; process.env.HTTPS_PROXY = proxyUrl; process.env.WS_PROXY = proxyUrl; + process.env.WSS_PROXY = proxyUrl; httpAgent = new ProxyAgent(); httpsAgent = httpAgent; // ProxyAgent automatically handles HTTPS const proxy = proxyUrl.replace(/:.*@/, "@******");