Respond when proxy errors

Otherwise the request will just hang.
This commit is contained in:
Asher 2020-04-08 11:54:18 -05:00
parent 363cdd02df
commit a288351ad4
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
1 changed files with 4 additions and 1 deletions

View File

@ -490,7 +490,10 @@ export class HttpServer {
} else {
this.server = http.createServer(this.onRequest)
}
this.proxy.on("error", (error) => logger.warn(error.message))
this.proxy.on("error", (error, _request, response) => {
response.writeHead(HttpCode.ServerError)
response.end(error.message)
})
// Intercept the response to rewrite absolute redirects against the base path.
this.proxy.on("proxyRes", (response, request: ProxyRequest) => {
if (response.headers.location && response.headers.location.startsWith("/") && request.base) {