Skip to content

Commit 73e1775

Browse files
authoredJun 14, 2022
feat: 500 response if the node proxy request fails (#7398)
1 parent 3aa54f7 commit 73e1775

File tree

1 file changed

+6
-1
lines changed
  • packages/vite/src/node/server/middlewares

1 file changed

+6
-1
lines changed
 

‎packages/vite/src/node/server/middlewares/proxy.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@ export function proxyMiddleware(
4343
}
4444
const proxy = httpProxy.createProxyServer(opts) as HttpProxy.Server
4545

46-
proxy.on('error', (err) => {
46+
proxy.on('error', (err, req, res) => {
4747
config.logger.error(`${colors.red(`http proxy error:`)}\n${err.stack}`, {
4848
timestamp: true,
4949
error: err
5050
})
51+
res
52+
.writeHead(500, {
53+
'Content-Type': 'text/plain'
54+
})
55+
.end()
5156
})
5257

5358
if (opts.configure) {

0 commit comments

Comments
 (0)
Please sign in to comment.