From 08350ec0efe84eabbb3e950fcdce6d470fe6c555 Mon Sep 17 00:00:00 2001 From: WK Date: Sun, 30 Aug 2020 14:52:20 +0800 Subject: [PATCH] Update subchannel.ts --- packages/grpc-js/src/subchannel.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/grpc-js/src/subchannel.ts b/packages/grpc-js/src/subchannel.ts index 736562a6..87805246 100644 --- a/packages/grpc-js/src/subchannel.ts +++ b/packages/grpc-js/src/subchannel.ts @@ -467,11 +467,13 @@ export class Subchannel { * if a connection is successfully established through the proxy. * If the proxy is not used, these connectionOptions are discarded * anyway */ - connectionOptions.servername = getDefaultAuthority( + const targetPath = getDefaultAuthority( parseUri(this.options['grpc.http_connect_target'] as string) ?? { path: 'localhost', } ); + const hostPort = splitHostPort(targetPath); + connectionOptions.servername = (hostPort !== null) ? hostPort.host : targetPath; } } }