mirror of
https://github.com/n8n-io/n8n.git
synced 2025-11-20 17:46:34 +00:00
fix the problem that axios don't use the http proxy #21199
This commit is contained in:
parent
9a54024b4a
commit
496a43e02b
@ -268,6 +268,16 @@ export async function invokeAxios(
|
||||
axiosConfig: AxiosRequestConfig,
|
||||
authOptions: IRequestOptions['auth'] = {},
|
||||
) {
|
||||
// axios not apply the http.globalAgent, need set it manually
|
||||
const url = process.env.HTTP_PROXY ?? process.env.HTTPS_PROXY ?? process.env.ALL_PROXY;
|
||||
if (url) {
|
||||
const parsedUrl = new URL(url);
|
||||
axiosConfig.proxy = {
|
||||
host: parsedUrl.hostname,
|
||||
port: parseInt(parsedUrl.port) || (parsedUrl.protocol === 'https:' ? 443 : 80),
|
||||
protocol: parsedUrl.protocol.replace(':', ''),
|
||||
};
|
||||
}
|
||||
try {
|
||||
return await axios(axiosConfig);
|
||||
} catch (error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user