fix: pass app-level proxy config to bru.sendRequest (#7113)

When collection proxy is set to "inherit", bru.sendRequest was skipping
the app-level proxy and falling through directly to system proxy. Now it
correctly checks app-level proxy settings first, matching the behavior
of normal requests. When appLevelProxyConfig is not provided (e.g. CLI),
falls through to system proxy preserving existing behavior.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
lohit
2026-02-11 13:38:37 +00:00
committed by Bijin A B
parent 78af8be59e
commit 6d646e3cef
2 changed files with 33 additions and 5 deletions

View File

@@ -207,6 +207,9 @@ const buildCertsAndProxyConfig = async ({
const collectionProxyConfig = get(brunoConfig, 'proxy', {});
const collectionLevelProxy = interpolateObject(collectionProxyConfig, interpolationOptions);
// Get app-level proxy config from global preferences
const appLevelProxyConfig = preferencesUtil.getGlobalProxyConfig();
// Get system proxy config
const systemProxyConfig = getCachedSystemProxy();
@@ -215,6 +218,7 @@ const buildCertsAndProxyConfig = async ({
options,
clientCertificates,
collectionLevelProxy,
appLevelProxyConfig,
systemProxyConfig
};
};

View File

@@ -103,6 +103,7 @@ type GetCertsAndProxyConfigParams = {
certs?: ClientCertificate[];
};
collectionLevelProxy?: ProxyConfig;
appLevelProxyConfig?: Record<string, any>;
systemProxyConfig?: SystemProxyConfig;
};
@@ -129,6 +130,7 @@ type GetHttpHttpsAgentsParams = {
certs?: ClientCertificate[];
};
collectionLevelProxy?: ProxyConfig;
appLevelProxyConfig?: Record<string, any>;
systemProxyConfig?: SystemProxyConfig;
};
@@ -210,6 +212,7 @@ const getCertsAndProxyConfig = ({
options,
clientCertificates,
collectionLevelProxy,
appLevelProxyConfig,
systemProxyConfig
}: GetCertsAndProxyConfigParams): GetCertsAndProxyConfigResult => {
const certsConfig: CertsConfig = {};
@@ -302,12 +305,31 @@ const getCertsAndProxyConfig = ({
proxyConfig = collectionProxyConfigData;
proxyMode = 'on';
} else if (!collectionProxyDisabled && collectionProxyInherit) {
// Inherit from system proxy
const { http_proxy, https_proxy } = systemProxyConfig || {};
if (http_proxy?.length || https_proxy?.length) {
proxyMode = 'system';
// Inherit from app-level proxy settings
if (appLevelProxyConfig) {
const globalDisabled = get(appLevelProxyConfig, 'disabled', false);
const globalInherit = get(appLevelProxyConfig, 'inherit', false);
const globalProxyConfigData = get(appLevelProxyConfig, 'config', appLevelProxyConfig);
if (!globalDisabled && !globalInherit) {
// Use app-level custom proxy
proxyConfig = globalProxyConfigData;
proxyMode = 'on';
} else if (!globalDisabled && globalInherit) {
// App-level also inherits, fall through to system proxy
const { http_proxy, https_proxy } = systemProxyConfig || {};
if (http_proxy?.length || https_proxy?.length) {
proxyMode = 'system';
}
}
// else: app-level proxy is disabled, proxyMode stays 'off'
} else {
// No app-level proxy config (e.g. CLI), fall through to system proxy
const { http_proxy, https_proxy } = systemProxyConfig || {};
if (http_proxy?.length || https_proxy?.length) {
proxyMode = 'system';
}
}
// else: no system proxy available, proxyMode stays 'off'
}
// else: collection proxy is disabled, proxyMode stays 'off'
@@ -409,6 +431,7 @@ const getHttpHttpsAgents = async ({
collectionPath,
clientCertificates,
collectionLevelProxy,
appLevelProxyConfig,
systemProxyConfig,
options
}: GetHttpHttpsAgentsParams): Promise<AgentResult> => {
@@ -417,6 +440,7 @@ const getHttpHttpsAgents = async ({
collectionPath,
clientCertificates,
collectionLevelProxy,
appLevelProxyConfig,
systemProxyConfig,
options
});