fixes: #11758 with a workaround with https proxy-agent

This commit is contained in:
Tristan Robert 2024-11-15 15:59:57 +01:00
parent bd924c7194
commit 58432de408
4 changed files with 270 additions and 148 deletions

View file

@ -91,5 +91,8 @@
"@types/ws@8.5.4": "patches/@types__ws@8.5.4.patch", "@types/ws@8.5.4": "patches/@types__ws@8.5.4.patch",
"@types/uuencode@0.0.3": "patches/@types__uuencode@0.0.3.patch" "@types/uuencode@0.0.3": "patches/@types__uuencode@0.0.3.patch"
} }
},
"dependencies": {
"proxy-agent": "^6.4.0"
} }
} }

View file

@ -179,6 +179,8 @@ import {
import { ScheduledTaskManager } from './ScheduledTaskManager'; import { ScheduledTaskManager } from './ScheduledTaskManager';
import { getSecretsProxy } from './Secrets'; import { getSecretsProxy } from './Secrets';
import { SSHClientsManager } from './SSHClientsManager'; import { SSHClientsManager } from './SSHClientsManager';
import { ProxyAgent } from 'proxy-agent';
import https from 'https';
axios.defaults.timeout = 300000; axios.defaults.timeout = 300000;
// Prevent axios from adding x-form-www-urlencoded headers by default // Prevent axios from adding x-form-www-urlencoded headers by default
@ -532,8 +534,8 @@ export async function parseRequestObject(requestObject: IRequestOptions) {
agentOptions.secureOptions = crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT; agentOptions.secureOptions = crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT;
} }
axiosConfig.httpsAgent = new Agent(agentOptions); axiosConfig.httpsAgent = new ProxyAgent({ httpsAgent: new https.Agent(agentOptions) });
axiosConfig.proxy = false;
axiosConfig.beforeRedirect = getBeforeRedirectFn(agentOptions, axiosConfig); axiosConfig.beforeRedirect = getBeforeRedirectFn(agentOptions, axiosConfig);
if (requestObject.timeout !== undefined) { if (requestObject.timeout !== undefined) {
@ -945,8 +947,8 @@ function convertN8nRequestToAxios(n8nRequest: IHttpRequestOptions): AxiosRequest
if (n8nRequest.skipSslCertificateValidation === true) { if (n8nRequest.skipSslCertificateValidation === true) {
agentOptions.rejectUnauthorized = false; agentOptions.rejectUnauthorized = false;
} }
axiosRequest.httpsAgent = new Agent(agentOptions); axiosRequest.httpsAgent = new ProxyAgent({ httpsAgent: new https.Agent(agentOptions) });
axiosRequest.proxy = false;
axiosRequest.beforeRedirect = getBeforeRedirectFn(agentOptions, axiosRequest); axiosRequest.beforeRedirect = getBeforeRedirectFn(agentOptions, axiosRequest);
if (n8nRequest.arrayFormat !== undefined) { if (n8nRequest.arrayFormat !== undefined) {

File diff suppressed because it is too large Load diff

View file

@ -13,6 +13,7 @@ catalog:
'@types/uuid': ^10.0.0 '@types/uuid': ^10.0.0
'@types/xml2js': ^0.4.14 '@types/xml2js': ^0.4.14
axios: 1.7.4 axios: 1.7.4
proxy-agent: 6.4.0
basic-auth: 2.0.1 basic-auth: 2.0.1
chokidar: 4.0.1 chokidar: 4.0.1
fast-glob: 3.2.12 fast-glob: 3.2.12