Skip to content

Commit 1f148e9

Browse files
committed
Fix missing port in proxy CONNECT when using the default HTTPS port
1 parent 51b0f66 commit 1f148e9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/grpc-js/src/http_proxy.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,16 @@ export function getProxiedConnection(
189189
if (parsedTarget === null) {
190190
return Promise.resolve<ProxyConnectionResult>({});
191191
}
192+
const targetHostPost = splitHostPort(parsedTarget.path);
193+
if (targetHostPost === null) {
194+
return Promise.resolve<ProxyConnectionResult>({});
195+
}
192196
const options: http.RequestOptions = {
193197
method: 'CONNECT',
194-
path: parsedTarget.path,
198+
path: targetHostPost.host + ':' + (targetHostPost.port != null ? targetHostPost.port : '443'),
195199
};
196200
const headers: http.OutgoingHttpHeaders = {
197-
Host: parsedTarget.path,
201+
Host: targetHostPost.host + ':' + (targetHostPost.port != null ? targetHostPost.port : '443'),
198202
};
199203
// Connect to the subchannel address as a proxy
200204
if (isTcpSubchannelAddress(address)) {

0 commit comments

Comments
 (0)