We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a9d61da commit a4bdf6cCopy full SHA for a4bdf6c
src/node/proxy.ts
@@ -3,9 +3,13 @@ import { HttpCode } from "../common/http"
3
4
export const proxy = proxyServer.createProxyServer({})
5
6
+// The error handler catches when the proxy fails to connect (for example when
7
+// there is nothing running on the target port).
8
proxy.on("error", (error, _, res) => {
- res.writeHead(HttpCode.ServerError)
- res.end(error.message)
9
+ // This could be for either a web socket or a regular request. Despite what
10
+ // the types say, writeHead() will not exist on web socket requests (nor will
11
+ // status() from Express) so write out the code manually.
12
+ res.end(`HTTP/1.1 ${HttpCode.ServerError} ${error.message}\r\n\r\n`)
13
})
14
15
// Intercept the response to rewrite absolute redirects against the base path.
0 commit comments