Skip to content

Commit a28b41b

Browse files
authored
Merge pull request #4565 from martinfrancois/fixProxyLocalRequests
fix: use proxy only for remote requests
2 parents 9283d29 + 61d77ac commit a28b41b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/common/http-client.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ private defaultUserAgent: string;
289289
* @param {string} requestProto The protocol used for the current request - http or https.
290290
*/
291291
private async useProxySettings(proxySettings: IProxySettings, cliProxySettings: IProxySettings, options: any, headers: any, requestProto: string): Promise<void> {
292-
if (proxySettings || cliProxySettings) {
292+
const isLocalRequest = options.host === "localhost" || options.host === "127.0.0.1";
293+
// don't use the proxy for requests to localhost
294+
if (!isLocalRequest && (proxySettings || cliProxySettings)) {
293295
const proto = (proxySettings && proxySettings.protocol) || cliProxySettings.protocol || "http:";
294296
const host = (proxySettings && proxySettings.hostname) || cliProxySettings.hostname;
295297
const port = (proxySettings && proxySettings.port) || cliProxySettings.port;

0 commit comments

Comments
 (0)