We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
vitejs
Learn more about funding links in repositories.
Report abuse
1 parent a376a43 commit 4afbccbCopy full SHA for 4afbccb
packages/vite/src/node/server/middlewares/proxy.ts
@@ -91,6 +91,17 @@ export function proxyMiddleware(
91
})
92
93
94
+ // https://github.com/http-party/node-http-proxy/issues/1520#issue-877626125
95
+ // https://github.com/chimurai/http-proxy-middleware/blob/cd58f962aec22c925b7df5140502978da8f87d5f/src/plugins/default/debug-proxy-errors-plugin.ts#L25-L37
96
+ proxy.on('proxyRes', (proxyRes, req, res) => {
97
+ res.on('close', () => {
98
+ if (!res.writableEnded) {
99
+ debug?.('destroying proxyRes in proxyRes close event')
100
+ proxyRes.destroy()
101
+ }
102
+ })
103
104
+
105
// clone before saving because http-proxy mutates the options
106
proxies[context] = [proxy, { ...opts }]
107
0 commit comments