From 0e7a7ceec9bfa5fa9666ee4e0f04e0c1342c3405 Mon Sep 17 00:00:00 2001 From: suyao Date: Fri, 28 Feb 2025 23:05:37 +0800 Subject: [PATCH] fix: The proxy configuration is not correctly passed. --- src/main/services/KnowledgeService.ts | 2 ++ src/main/services/ProxyManager.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/src/main/services/KnowledgeService.ts b/src/main/services/KnowledgeService.ts index 89d991b5e0..07e588cfd8 100644 --- a/src/main/services/KnowledgeService.ts +++ b/src/main/services/KnowledgeService.ts @@ -13,6 +13,7 @@ import { getAllFiles } from '@main/utils/file' import type { LoaderReturn } from '@shared/config/types' import { FileType, KnowledgeBaseParams, KnowledgeItem } from '@types' import { app } from 'electron' +import { ProxyAgent, setGlobalDispatcher } from 'undici' import { v4 as uuidv4 } from 'uuid' import { proxyManager } from './ProxyManager' @@ -85,6 +86,7 @@ class KnowledgeService { _: Electron.IpcMainInvokeEvent, { base, item, forceReload = false }: { base: KnowledgeBaseParams; item: KnowledgeItem; forceReload: boolean } ): Promise => { + setGlobalDispatcher(new ProxyAgent(proxyManager.getProxyUrl() || '')) const ragApplication = await this.getRagApplication(base) const sendDirectoryProcessingPercent = (totalFiles: number, processedFiles: number) => { diff --git a/src/main/services/ProxyManager.ts b/src/main/services/ProxyManager.ts index 6a4b0fc2db..5bd80fb777 100644 --- a/src/main/services/ProxyManager.ts +++ b/src/main/services/ProxyManager.ts @@ -66,6 +66,7 @@ export class ProxyManager { private async setCustomProxy(): Promise { try { if (this.config.url) { + this.proxyUrl = this.config.url this.proxyAgent = new HttpsProxyAgent(this.config.url) this.setEnvironment(this.config.url) await this.setSessionsProxy({ proxyRules: this.config.url })