MCPcopy
hub / github.com/prisma/prisma / getProxyAgent

Function getProxyAgent

packages/fetch-engine/src/getProxyAgent.ts:87–116  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

85}
86
87export function getProxyAgent(url: string): HttpProxyAgent<string> | HttpsProxyAgent<string> | undefined {
88 try {
89 const uri = new URL(url)
90 const proxy = getProxyFromURI(uri)
91
92 if (!proxy) {
93 return undefined
94 } else if (uri.protocol === 'http:') {
95 try {
96 return new HttpProxyAgent(proxy)
97 } catch (agentError) {
98 throw new Error(
99 `Error while instantiating HttpProxyAgent with URL: "${proxy}"\n${agentError}\nCheck the following env vars "http_proxy" or "HTTP_PROXY". The value should be a valid URL starting with "http://"`,
100 )
101 }
102 } else if (uri.protocol === 'https:') {
103 try {
104 return new HttpsProxyAgent(proxy)
105 } catch (agentError) {
106 throw new Error(
107 `Error while instantiating HttpsProxyAgent with URL: "${proxy}"\n${agentError}\nCheck the following env vars "https_proxy" or "HTTPS_PROXY". The value should be a valid URL starting with "https://"`,
108 )
109 }
110 }
111 } catch (e) {
112 console.warn(`An error occurred in getProxyAgent(), no proxy agent will be used.`, e)
113 }
114
115 return undefined
116}

Callers 5

uploadZipFunction · 0.90
requestFunction · 0.90
fetchChecksumFunction · 0.90
downloadZipFunction · 0.90

Calls 2

getProxyFromURIFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected