From 67bc9932e5644d00a812862dbc3dcd2cfd3bfb29 Mon Sep 17 00:00:00 2001 From: Dominic Cooney Date: Tue, 11 Nov 2025 02:54:54 +0900 Subject: [PATCH] Add proxy configuration to more network fetches. (#7328) --- .changeset/free-nights-notice.md | 5 +++++ src/core/controller/index.ts | 4 +++- src/core/controller/mcp/downloadMcp.ts | 2 ++ src/core/controller/models/getAihubmixModels.ts | 3 ++- src/core/controller/models/getOllamaModels.ts | 3 ++- src/core/controller/models/getSapAiCoreModels.ts | 4 +++- src/core/controller/models/refreshBasetenModels.ts | 2 ++ src/core/controller/models/refreshGroqModels.ts | 2 ++ src/core/controller/models/refreshHicapModels.ts | 2 ++ src/core/controller/models/refreshHuggingFaceModels.ts | 2 ++ src/core/controller/models/refreshOpenAiModels.ts | 3 ++- src/core/controller/models/refreshOpenRouterModels.ts | 3 ++- src/core/controller/models/refreshRequestyModels.ts | 3 ++- src/core/controller/models/refreshVercelAiGatewayModels.ts | 3 ++- src/core/storage/remote-config/fetch.ts | 2 ++ src/integrations/misc/link-preview.ts | 2 ++ src/services/account/ClineAccountService.ts | 2 ++ src/services/auth/oca/providers/OcaAuthProvider.ts | 4 ++-- src/services/auth/providers/ClineAuthProvider.ts | 3 ++- src/services/auth/providers/FirebaseAuthProvider.ts | 3 +++ src/services/banner/BannerService.ts | 2 ++ 21 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 .changeset/free-nights-notice.md diff --git a/.changeset/free-nights-notice.md b/.changeset/free-nights-notice.md new file mode 100644 index 00000000..1aa22377 --- /dev/null +++ b/.changeset/free-nights-notice.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Use HTTP proxies in more places diff --git a/src/core/controller/index.ts b/src/core/controller/index.ts index e90d32ef..43e3742f 100644 --- a/src/core/controller/index.ts +++ b/src/core/controller/index.ts @@ -33,6 +33,7 @@ import { LogoutReason } from "@/services/auth/types" import { featureFlagsService } from "@/services/feature-flags" import { getDistinctId } from "@/services/logging/distinctId" import { telemetryService } from "@/services/telemetry" +import { getAxiosSettings } from "@/shared/net" import { ShowMessageType } from "@/shared/proto/host/window" import { AuthState } from "@/shared/proto/index.cline" import { getLatestAnnouncementId } from "@/utils/announcements" @@ -651,6 +652,7 @@ export class Controller { "Content-Type": "application/json", "User-Agent": "cline-vscode-extension", }, + ...getAxiosSettings(), }) if (!response.data) { @@ -698,7 +700,7 @@ export class Controller { async handleOpenRouterCallback(code: string) { let apiKey: string try { - const response = await axios.post("https://openrouter.ai/api/v1/auth/keys", { code }) + const response = await axios.post("https://openrouter.ai/api/v1/auth/keys", { code }, getAxiosSettings()) if (response.data && response.data.key) { apiKey = response.data.key } else { diff --git a/src/core/controller/mcp/downloadMcp.ts b/src/core/controller/mcp/downloadMcp.ts index 2bf9602b..e3c7859f 100644 --- a/src/core/controller/mcp/downloadMcp.ts +++ b/src/core/controller/mcp/downloadMcp.ts @@ -3,6 +3,7 @@ import { StringRequest } from "@shared/proto/cline/common" import { McpDownloadResponse } from "@shared/proto/cline/mcp" import axios from "axios" import { ClineEnv } from "@/config" +import { getAxiosSettings } from "@/shared/net" import { Controller } from ".." import { sendChatButtonClickedEvent } from "../ui/subscribeToChatButtonClicked" @@ -36,6 +37,7 @@ export async function downloadMcp(controller: Controller, request: StringRequest { headers: { "Content-Type": "application/json" }, timeout: 10000, + ...getAxiosSettings(), }, ) diff --git a/src/core/controller/models/getAihubmixModels.ts b/src/core/controller/models/getAihubmixModels.ts index efbcb6cc..140f7287 100644 --- a/src/core/controller/models/getAihubmixModels.ts +++ b/src/core/controller/models/getAihubmixModels.ts @@ -1,6 +1,7 @@ import { EmptyRequest } from "@shared/proto/cline/common" import { OpenRouterCompatibleModelInfo, OpenRouterModelInfo } from "@shared/proto/cline/models" import axios from "axios" +import { getAxiosSettings } from "@/shared/net" import { Controller } from ".." /** @@ -11,7 +12,7 @@ import { Controller } from ".." */ export async function getAihubmixModels(_controller: Controller, _request: EmptyRequest): Promise { try { - const response = await axios.get("https://aihubmix.com/call/mdl_info_platform?tag=coding") + const response = await axios.get("https://aihubmix.com/call/mdl_info_platform?tag=coding", getAxiosSettings()) if (!response.data?.success || !Array.isArray(response.data?.data)) { console.error("Invalid response from AIhubmix API:", response.data) diff --git a/src/core/controller/models/getOllamaModels.ts b/src/core/controller/models/getOllamaModels.ts index e525c5fe..ee015d69 100644 --- a/src/core/controller/models/getOllamaModels.ts +++ b/src/core/controller/models/getOllamaModels.ts @@ -1,5 +1,6 @@ import { StringArray, StringRequest } from "@shared/proto/cline/common" import axios from "axios" +import { getAxiosSettings } from "@/shared/net" import { Controller } from ".." /** @@ -16,7 +17,7 @@ export async function getOllamaModels(_controller: Controller, request: StringRe return StringArray.create({ values: [] }) } - const response = await axios.get(`${baseUrl}/api/tags`) + const response = await axios.get(`${baseUrl}/api/tags`, getAxiosSettings()) const modelsArray = response.data?.models?.map((model: any) => model.name) || [] const models = [...new Set(modelsArray)].sort() diff --git a/src/core/controller/models/getSapAiCoreModels.ts b/src/core/controller/models/getSapAiCoreModels.ts index db9ff9c1..1de672e5 100644 --- a/src/core/controller/models/getSapAiCoreModels.ts +++ b/src/core/controller/models/getSapAiCoreModels.ts @@ -1,4 +1,5 @@ import axios from "axios" +import { getAxiosSettings } from "@/shared/net" import { SapAiCoreModelDeployment, SapAiCoreModelsRequest, SapAiCoreModelsResponse } from "@/shared/proto/cline/models" import { Controller } from ".." @@ -33,6 +34,7 @@ async function getToken(clientId: string, clientSecret: string, tokenUrl: string const url = tokenUrl.replace(/\/+$/, "") + "/oauth/token" const response = await axios.post(url, payload, { headers: { "Content-Type": "application/x-www-form-urlencoded" }, + ...getAxiosSettings(), }) const token = response.data as Token token.expires_at = Date.now() + token.expires_in * 1000 @@ -65,7 +67,7 @@ async function fetchAiCoreDeploymentsAndOrchestration( const url = `${baseUrl}/v2/lm/deployments?$top=10000&$skip=0` try { - const response = await axios.get(url, { headers }) + const response = await axios.get(url, { headers, ...getAxiosSettings() }) const allDeployments = response.data.resources // Filter running deployments diff --git a/src/core/controller/models/refreshBasetenModels.ts b/src/core/controller/models/refreshBasetenModels.ts index 8c4f3c02..1ab2916a 100644 --- a/src/core/controller/models/refreshBasetenModels.ts +++ b/src/core/controller/models/refreshBasetenModels.ts @@ -5,6 +5,7 @@ import { parsePrice } from "@utils/model-utils" import axios from "axios" import fs from "fs/promises" import path from "path" +import { getAxiosSettings } from "@/shared/net" import { basetenModels } from "../../../shared/api" import { Controller } from ".." @@ -50,6 +51,7 @@ export async function refreshBasetenModels(controller: Controller): Promise model.id) || [] const models = [...new Set(modelsArray)] diff --git a/src/core/controller/models/refreshOpenRouterModels.ts b/src/core/controller/models/refreshOpenRouterModels.ts index c46ca389..c80d0691 100644 --- a/src/core/controller/models/refreshOpenRouterModels.ts +++ b/src/core/controller/models/refreshOpenRouterModels.ts @@ -10,6 +10,7 @@ import { openRouterClaudeSonnet41mModelId, openRouterClaudeSonnet451mModelId, } from "@/shared/api" +import { getAxiosSettings } from "@/shared/net" import type { Controller } from ".." type OpenRouterSupportedParams = @@ -79,7 +80,7 @@ export async function refreshOpenRouterModels(controller: Controller): Promise = {} try { - const response = await axios.get("https://openrouter.ai/api/v1/models") + const response = await axios.get("https://openrouter.ai/api/v1/models", getAxiosSettings()) if (response.data?.data) { const rawModels = response.data.data diff --git a/src/core/controller/models/refreshRequestyModels.ts b/src/core/controller/models/refreshRequestyModels.ts index 5a96acf9..79842377 100644 --- a/src/core/controller/models/refreshRequestyModels.ts +++ b/src/core/controller/models/refreshRequestyModels.ts @@ -1,6 +1,7 @@ import { EmptyRequest } from "@shared/proto/cline/common" import { OpenRouterCompatibleModelInfo, OpenRouterModelInfo } from "@shared/proto/cline/models" import axios from "axios" +import { getAxiosSettings } from "@/shared/net" import { toRequestyServiceUrl } from "@/shared/clients/requesty" import { Controller } from ".." @@ -33,7 +34,7 @@ export async function refreshRequestyModels(controller: Controller, _: EmptyRequ const headers = { Authorization: `Bearer ${apiKey}`, } - const response = await axios.get(url, { headers }) + const response = await axios.get(url, { headers, ...getAxiosSettings() }) if (response.data?.data) { for (const model of response.data.data) { const modelInfo: OpenRouterModelInfo = OpenRouterModelInfo.create({ diff --git a/src/core/controller/models/refreshVercelAiGatewayModels.ts b/src/core/controller/models/refreshVercelAiGatewayModels.ts index 41b1037e..e883f923 100644 --- a/src/core/controller/models/refreshVercelAiGatewayModels.ts +++ b/src/core/controller/models/refreshVercelAiGatewayModels.ts @@ -4,6 +4,7 @@ import { fileExistsAtPath } from "@utils/fs" import axios from "axios" import fs from "fs/promises" import path from "path" +import { getAxiosSettings } from "@/shared/net" import { Controller } from ".." /** @@ -17,7 +18,7 @@ export async function refreshVercelAiGatewayModels(_controller: Controller): Pro let models: Record = {} try { - const response = await axios.get("https://ai-gateway.vercel.sh/v1/models") + const response = await axios.get("https://ai-gateway.vercel.sh/v1/models", getAxiosSettings()) if (response.data?.data) { const rawModels = response.data.data diff --git a/src/core/storage/remote-config/fetch.ts b/src/core/storage/remote-config/fetch.ts index effa3887..d63e976b 100644 --- a/src/core/storage/remote-config/fetch.ts +++ b/src/core/storage/remote-config/fetch.ts @@ -1,5 +1,6 @@ import axios, { AxiosRequestConfig, AxiosResponse } from "axios" import { Controller } from "@/core/controller" +import { getAxiosSettings } from "@/shared/net" import { ClineEnv } from "../../../config" import { AuthService } from "../../../services/auth/AuthService" import { CLINE_API_ENDPOINT } from "../../../shared/cline/api" @@ -35,6 +36,7 @@ async function fetchRemoteConfigForOrganization(organizationId: string): Promise Authorization: `Bearer ${authToken}`, "Content-Type": "application/json", }, + ...getAxiosSettings(), } const response: AxiosResponse<{ diff --git a/src/integrations/misc/link-preview.ts b/src/integrations/misc/link-preview.ts index e96a2d05..8466e7f6 100644 --- a/src/integrations/misc/link-preview.ts +++ b/src/integrations/misc/link-preview.ts @@ -1,5 +1,6 @@ import axios from "axios" import ogs from "open-graph-scraper" +import { getAxiosSettings } from "@/shared/net" export interface OpenGraphData { title?: string @@ -94,6 +95,7 @@ export async function detectImageUrl(url: string): Promise { "User-Agent": "Mozilla/5.0 (compatible; VSCodeExtension/1.0; +https://cline.bot)", }, timeout: 3000, + ...getAxiosSettings(), }) const contentType = response.headers["content-type"] diff --git a/src/services/account/ClineAccountService.ts b/src/services/account/ClineAccountService.ts index 9317e1ee..c16e2106 100644 --- a/src/services/account/ClineAccountService.ts +++ b/src/services/account/ClineAccountService.ts @@ -9,6 +9,7 @@ import type { import axios, { AxiosRequestConfig, AxiosResponse } from "axios" import { ClineEnv } from "@/config" import { CLINE_API_ENDPOINT } from "@/shared/cline/api" +import { getAxiosSettings } from "@/shared/net" import { AuthService } from "../auth/AuthService" export class ClineAccountService { @@ -60,6 +61,7 @@ export class ClineAccountService { "Content-Type": "application/json", ...config.headers, }, + ...getAxiosSettings(), } const response: AxiosResponse<{ data?: T; error: string; success: boolean }> = await axios.request({ url, diff --git a/src/services/auth/oca/providers/OcaAuthProvider.ts b/src/services/auth/oca/providers/OcaAuthProvider.ts index a70e798b..0c910728 100644 --- a/src/services/auth/oca/providers/OcaAuthProvider.ts +++ b/src/services/auth/oca/providers/OcaAuthProvider.ts @@ -102,7 +102,7 @@ export class OcaAuthProvider { if (!idcs_url || !client_id) { throw new Error("IDCS URL or Client ID are not configured") } - const discovery = await axios.get(`${idcs_url}/.well-known/openid-configuration`, { ...getAxiosSettings() }) + const discovery = await axios.get(`${idcs_url}/.well-known/openid-configuration`, getAxiosSettings()) const tokenEndpoint = discovery.data.token_endpoint const params: any = { grant_type: "refresh_token", @@ -183,7 +183,7 @@ export class OcaAuthProvider { } const { code_verifier, nonce, redirect_uri } = entry OcaAuthProvider.pkceStateMap.delete(state) - const discovery = await axios.get(`${idcs_url}/.well-known/openid-configuration`, { ...getAxiosSettings() }) + const discovery = await axios.get(`${idcs_url}/.well-known/openid-configuration`, getAxiosSettings()) const tokenEndpoint = discovery.data.token_endpoint const params: any = { grant_type: "authorization_code", diff --git a/src/services/auth/providers/ClineAuthProvider.ts b/src/services/auth/providers/ClineAuthProvider.ts index f079f7ac..37b7354b 100644 --- a/src/services/auth/providers/ClineAuthProvider.ts +++ b/src/services/auth/providers/ClineAuthProvider.ts @@ -4,7 +4,7 @@ import { Controller } from "@/core/controller" import { HostProvider } from "@/hosts/host-provider" import { Logger } from "@/services/logging/Logger" import { CLINE_API_ENDPOINT } from "@/shared/cline/api" -import { fetch } from "@/shared/net" +import { fetch, getAxiosSettings } from "@/shared/net" import type { ClineAccountUserInfo, ClineAuthInfo } from "../AuthService" import { IAuthProvider } from "./IAuthProvider" @@ -306,6 +306,7 @@ export class ClineAuthProvider implements IAuthProvider { headers: { Authorization: `Bearer workos:${tokenData.accessToken}`, }, + ...getAxiosSettings(), }) return userResponse.data.data diff --git a/src/services/auth/providers/FirebaseAuthProvider.ts b/src/services/auth/providers/FirebaseAuthProvider.ts index 9b539c08..27eec7dc 100644 --- a/src/services/auth/providers/FirebaseAuthProvider.ts +++ b/src/services/auth/providers/FirebaseAuthProvider.ts @@ -5,6 +5,7 @@ import { jwtDecode } from "jwt-decode" import { ClineEnv, EnvironmentConfig } from "@/config" import { Controller } from "@/core/controller" import { ErrorService } from "@/services/error" +import { getAxiosSettings } from "@/shared/net" import type { ClineAccountUserInfo, ClineAuthInfo } from "../AuthService" import { IAuthProvider } from "./IAuthProvider" @@ -55,6 +56,7 @@ export class FirebaseAuthProvider implements IAuthProvider { headers: { Authorization: `Bearer ${idToken}`, }, + ...getAxiosSettings(), }) // Store user data @@ -78,6 +80,7 @@ export class FirebaseAuthProvider implements IAuthProvider { headers: { "Content-Type": "application/x-www-form-urlencoded", }, + ...getAxiosSettings(), }, ) diff --git a/src/services/banner/BannerService.ts b/src/services/banner/BannerService.ts index abd8a5d2..41e8222d 100644 --- a/src/services/banner/BannerService.ts +++ b/src/services/banner/BannerService.ts @@ -4,6 +4,7 @@ import axios from "axios" import { ClineEnv } from "@/config" import type { Controller } from "@/core/controller" import { HostProvider } from "@/hosts/host-provider" +import { getAxiosSettings } from "@/shared/net" import { AuthService } from "../auth/AuthService" import { Logger } from "../logging/Logger" @@ -93,6 +94,7 @@ export class BannerService { headers: { "Content-Type": "application/json", }, + ...getAxiosSettings(), }) if (!response.data?.data?.banners) {