From eb95fa618d7923ab77bd457bbd0935ccd710a843 Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Fri, 23 Oct 2020 10:15:56 -0700 Subject: [PATCH] Set the default port of 80 explicitly in http_proxy --- packages/grpc-js/src/http_proxy.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/grpc-js/src/http_proxy.ts b/packages/grpc-js/src/http_proxy.ts index 84e29a50..f6921378 100644 --- a/packages/grpc-js/src/http_proxy.ts +++ b/packages/grpc-js/src/http_proxy.ts @@ -84,8 +84,16 @@ function getProxyInfo(): ProxyInfo { userCred = proxyUrl.username; } } + const hostname = proxyUrl.hostname; + let port = proxyUrl.port; + /* The proxy URL uses the scheme "http:", which has a default port number of + * 80. We need to set that explicitly here if it is omitted because otherwise + * it will use gRPC's default port 443. */ + if (port === '') { + port = '80'; + } const result: ProxyInfo = { - address: proxyUrl.host, + address: `${hostname}:${port}` }; if (userCred) { result.creds = userCred;