From b43a4fd2ea062c877818381c8b3ce1fec73f2d54 Mon Sep 17 00:00:00 2001 From: Hureru <3507039083@qq.com> Date: Mon, 16 Mar 2026 01:05:43 +0800 Subject: [PATCH] fix(proxy): use proxyUrl parameter in endpointFlow fetch The ExecuteEndpointFlowInput.proxyUrl field was defined but ignored by the fetch call. Apply it via withExplicitProxyRequestInit when present, falling back to withSiteProxyRequestInit otherwise. --- src/server/routes/proxy/endpointFlow.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/server/routes/proxy/endpointFlow.ts b/src/server/routes/proxy/endpointFlow.ts index c1e9336..33ebc72 100644 --- a/src/server/routes/proxy/endpointFlow.ts +++ b/src/server/routes/proxy/endpointFlow.ts @@ -1,5 +1,5 @@ import { fetch } from 'undici'; -import { withSiteProxyRequestInit } from '../../services/siteProxy.js'; +import { withExplicitProxyRequestInit, withSiteProxyRequestInit } from '../../services/siteProxy.js'; import { summarizeUpstreamError } from './upstreamError.js'; import type { UpstreamEndpoint } from './upstreamEndpoint.js'; import { buildUpstreamUrl } from './upstreamUrl.js'; @@ -69,11 +69,17 @@ export async function executeEndpointFlow(input: ExecuteEndpointFlowInput): Prom const request = input.buildRequest(endpoint, endpointIndex); const targetUrl = buildUpstreamUrl(input.siteUrl, request.path); - let response = await fetch(targetUrl, await withSiteProxyRequestInit(targetUrl, { - method: 'POST', - headers: request.headers, - body: JSON.stringify(request.body), - })); + let response = await fetch(targetUrl, input.proxyUrl + ? withExplicitProxyRequestInit(input.proxyUrl, { + method: 'POST', + headers: request.headers, + body: JSON.stringify(request.body), + }) + : await withSiteProxyRequestInit(targetUrl, { + method: 'POST', + headers: request.headers, + body: JSON.stringify(request.body), + })); if (response.ok) { return {