Add proxy configuration to more network fetches. (#7328)

This commit is contained in:
Dominic Cooney authored and GitHub committed 2025-11-10 09:54:54 -08:00
1 parent ba98b44504
commit 67bc9932e5
21 files changed
+48 -11

No files matched your search

+3 -1
View File
@@ -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 {
+2
View File
@@ -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(),
},
)
@@ -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<OpenRouterCompatibleModelInfo> {
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)
@@ -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<string>(modelsArray)].sort()
@@ -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
@@ -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<Reco
"User-Agent": "Cline-VSCode-Extension",
},
timeout: 10000, // 10 second timeout
...getAxiosSettings(),
})
if (response.data?.data) {
@@ -5,6 +5,7 @@ import axios from "axios"
import fs from "fs/promises"
import path from "path"
import { telemetryService } from "@/services/telemetry"
import { getAxiosSettings } from "@/shared/net"
import { groqModels } from "../../../shared/api"
import { Controller } from ".."
@@ -52,6 +53,7 @@ export async function refreshGroqModels(controller: Controller): Promise<Record<
"User-Agent": "Cline-VSCode-Extension",
},
timeout: 10000, // 10 second timeout
...getAxiosSettings(),
})
if (response.data?.data) {
@@ -5,6 +5,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 ".."
/**
@@ -33,6 +34,7 @@ export async function refreshHicapModels(controller: Controller, _request: Empty
headers: {
"api-key": hicapApiKey,
},
...getAxiosSettings(),
})
if (response.data?.data) {
@@ -6,6 +6,7 @@ import axios from "axios"
import fs from "fs/promises"
import path from "path"
import { ensureCacheDirectoryExists } from "@/core/storage/disk"
import { getAxiosSettings } from "@/shared/net"
import { Controller } from ".."
/**
@@ -26,6 +27,7 @@ export async function refreshHuggingFaceModels(
// Fetch models from Hugging Face API
const response = await axios.get("https://router.huggingface.co/v1/models", {
timeout: 10000,
...getAxiosSettings(),
})
if (response.data?.data) {
@@ -2,6 +2,7 @@ import { StringArray } from "@shared/proto/cline/common"
import { OpenAiModelsRequest } from "@shared/proto/cline/models"
import type { AxiosRequestConfig } from "axios"
import axios from "axios"
import { getAxiosSettings } from "@/shared/net"
import { Controller } from ".."
/**
@@ -25,7 +26,7 @@ export async function refreshOpenAiModels(_controller: Controller, request: Open
config["headers"] = { Authorization: `Bearer ${request.apiKey}` }
}
const response = await axios.get(`${request.baseUrl}/models`, config)
const response = await axios.get(`${request.baseUrl}/models`, { ...config, ...getAxiosSettings() })
const modelsArray = response.data?.data?.map((model: any) => model.id) || []
const models = [...new Set<string>(modelsArray)]
@@ -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<R
const models: Record<string, ModelInfo> = {}
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
@@ -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({
@@ -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<string, ModelInfo> = {}
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
+2
View File
@@ -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<{
+2
View File
@@ -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<boolean> {
"User-Agent": "Mozilla/5.0 (compatible; VSCodeExtension/1.0; +https://cline.bot)",
},
timeout: 3000,
...getAxiosSettings(),
})
const contentType = response.headers["content-type"]
@@ -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,
@@ -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",
@@ -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
@@ -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(),
},
)
+2
View File
@@ -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) {