From 02cc24f5e7c3219eb0dd77480f9df8208e81c09c Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 15 Jul 2020 15:07:39 -0400 Subject: [PATCH] fix: fallback to http1 when proxy is required fix #484 --- src/node/server/index.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/node/server/index.ts b/src/node/server/index.ts index 432c86f2965764..eb2e5a54c22b7b 100644 --- a/src/node/server/index.ts +++ b/src/node/server/index.ts @@ -125,17 +125,25 @@ export function createServer(config: ServerConfig): Server { } function resolveServer( - { https = false, httpsOptions = {} }: ServerConfig, + { https = false, httpsOptions = {}, proxy }: ServerConfig, requestListener: RequestListener ) { if (https) { - return require('http2').createSecureServer( - { - ...resolveHttpsConfig(httpsOptions), - allowHTTP1: true - }, - requestListener - ) + if (proxy) { + // #484 fallback to http1 when proxy is needed. + return require('https').createServer( + resolveHttpsConfig(httpsOptions), + requestListener + ) + } else { + return require('http2').createSecureServer( + { + ...resolveHttpsConfig(httpsOptions), + allowHTTP1: true + }, + requestListener + ) + } } else { return require('http').createServer(requestListener) }