Skip to content

Commit

Permalink
fix: fallback to http1 when proxy is required
Browse files Browse the repository at this point in the history
fix #484
  • Loading branch information
yyx990803 committed Jul 15, 2020
1 parent a502399 commit 02cc24f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 02cc24f

Please sign in to comment.