Skip to content

Commit 61d77ac

Browse files
fix: use proxy only for remote requests
Do not use the proxy for requests to localhost or 127.0.0.1 when NativeScript is configured to use the proxy. Partially fixes issue #2313, since requests to localhost will be possible in corporate proxy environments.
1 parent 8b83f91 commit 61d77ac

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)