Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix(proxy): use undici fetch to resolve Node 22 incompatibility with proxyDispatcher (#1056) test: update login-bootstrap-route metadata assertions
diegosouzapw4af7a1896c39
diff --git a/open-sse/utils/proxyFetch.ts b/open-sse/utils/proxyFetch.tsindex c439cb4fb9..dd56e5f0ee 100644--- a/open-sse/utils/proxyFetch.ts+++ b/open-sse/utils/proxyFetch.ts@@ -1,4 +1,5 @@import { AsyncLocalStorage } from "node:async_hooks";+import { fetch as undiciFetch } from "undici";import {createProxyDispatcher,getDefaultDispatcher,@@ -164,7 +165,7 @@ export async function runWithProxyContext(proxyConfig, fn) {async function patchedFetch(input: RequestInfo | URL, options: FetchWithDispatcherOptions = {}) {if (options?.dispatcher) {- return originalFetchWithDispatcher(input, options);+ return (undiciFetch as any)(input, options);}const targetUrl = getTargetUrl(input);@@ -197,7 +198,7 @@ async function patchedFetch(input: RequestInfo | URL, options: FetchWithDispatchif (store) store.used = false;}}- return originalFetchWithDispatcher(input, {+ return (undiciFetch as any)(input, {...options,dispatcher: getDefaultDispatcher(),});@@ -205,7 +206,7 @@ async function patchedFetch(input: RequestInfo | URL, options: FetchWithDispatchtry {const dispatcher = createProxyDispatcher(proxyUrl);- return await originalFetchWithDispatcher(input, { ...options, dispatcher });+ return await (undiciFetch as any)(input, { ...options, dispatcher });} catch (error) {const message = error instanceof Error ? error.message : String(error);console.error(`[ProxyFetch] Proxy request failed (${source}, fail-closed): ${message}`);diff --git a/tests/unit/login-bootstrap-route.test.mjs b/tests/unit/login-bootstrap-route.test.mjsindex 05c74fb30b..64c376cc94 100644--- a/tests/unit/login-bootstrap-route.test.mjs+++ b/tests/unit/login-bootstrap-route.test.mjs@@ -49,6 +49,8 @@ test("public login bootstrap route exposes the metadata the login page consumes"requireLogin: true,hasPassword: false,setupComplete: true,+ nodeVersion: body.nodeVersion,+ nodeCompatible: body.nodeCompatible,});});@@ -68,6 +70,8 @@ test("public login bootstrap route reports env-provided bootstrap password metadrequireLogin: true,hasPassword: true,setupComplete: true,+ nodeVersion: body.nodeVersion,+ nodeCompatible: body.nodeCompatible,});});@@ -86,6 +90,8 @@ test("public login bootstrap route reports stored password metadata and disabledrequireLogin: false,hasPassword: true,setupComplete: true,+ nodeVersion: body.nodeVersion,+ nodeCompatible: body.nodeCompatible,});});