Context7 Platform -- Up-to-date docs for AI agents
refactor: change PROXY_URL to const and remove unnecessary type cast in ProxyAgent
enesgules288d85304841
diff --git a/src/lib/api.ts b/src/lib/api.tsindex b7f09df1..f147e0d8 100644--- a/src/lib/api.ts+++ b/src/lib/api.ts@@ -6,7 +6,7 @@ const CONTEXT7_API_BASE_URL = "https://context7.com/api";const DEFAULT_TYPE = "txt";// Pick up proxy configuration in a variety of common env var names.-let PROXY_URL: string | null =+const PROXY_URL: string | null =process.env.HTTPS_PROXY ??process.env.https_proxy ??process.env.HTTP_PROXY ??@@ -19,7 +19,7 @@ if (PROXY_URL && !PROXY_URL.startsWith("$") && /^(http|https):\/\//i.test(PROXY_// automatically use this dispatcher.// Using `any` cast because ProxyAgent implements the Dispatcher interface but// TS may not infer it correctly in some versions.- setGlobalDispatcher(new ProxyAgent(PROXY_URL) as any);+ setGlobalDispatcher(new ProxyAgent(PROXY_URL));} catch (error) {// Don't crash the app if proxy initialisation fails – just log a warning.console.error(