From 99a0a19d8cdf987d16e52b932ec1e4ce01b7bf5b Mon Sep 17 00:00:00 2001 From: devlikepro Date: Mon, 2 Feb 2026 13:40:21 +0700 Subject: [PATCH] [core] NOWEB - fix send image using proxy fix #1859 --- src/core/engines/noweb/session.noweb.core.ts | 6 ++---- src/core/engines/noweb/types.ts | 3 +-- src/core/helpers.proxy.ts | 5 +++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/core/engines/noweb/session.noweb.core.ts b/src/core/engines/noweb/session.noweb.core.ts index c23543cc..42667a0b 100644 --- a/src/core/engines/noweb/session.noweb.core.ts +++ b/src/core/engines/noweb/session.noweb.core.ts @@ -355,10 +355,8 @@ export class WhatsappSessionNoWebCore extends WhatsappSession { } return { agent: agents?.socket, - // Baileys types still expect a Node https.Agent here, - // but 'undici' fetch requires a Dispatcher. - // Cast keeps the compiler satisfied while we pass the ProxyAgent at runtime. - fetchAgent: agents?.fetch as unknown as Agent, + // Baileys media upload uses Node https.request in Node runtime. + fetchAgent: agents?.fetch as Agent, auth: state, printQRInTerminal: false, browser: browser, diff --git a/src/core/engines/noweb/types.ts b/src/core/engines/noweb/types.ts index a4da0381..12ea846f 100644 --- a/src/core/engines/noweb/types.ts +++ b/src/core/engines/noweb/types.ts @@ -1,7 +1,6 @@ import { Agent } from 'https'; -import type { Dispatcher } from 'undici'; export interface Agents { socket: Agent; - fetch: Dispatcher; + fetch: Agent; } diff --git a/src/core/helpers.proxy.ts b/src/core/helpers.proxy.ts index 248ae0a7..07433993 100644 --- a/src/core/helpers.proxy.ts +++ b/src/core/helpers.proxy.ts @@ -1,6 +1,5 @@ import { HttpsProxyAgent } from 'https-proxy-agent'; import { URL } from 'url'; -import { ProxyAgent } from 'undici'; import { WhatsappConfigService } from '../config.service'; import { ProxyConfig } from '../structures/sessions.dto'; @@ -72,7 +71,9 @@ export function createAgentProxy(proxyConfig: ProxyConfig): Agents | undefined { ); const socketAgent = new HttpsProxyAgent(url); - const fetchAgent = new ProxyAgent({ uri: url }); + // Baileys media upload uses Node.js https.request in Node runtime, + // so fetchAgent must be a Node https.Agent (ProxyAgent from undici won't work). + const fetchAgent = new HttpsProxyAgent(url); return { socket: socketAgent, fetch: fetchAgent }; }