Skip to content

Commit

Permalink
feat: 500 response if the node proxy request fails (#7398)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbergstroem authored Jun 14, 2022
1 parent 3aa54f7 commit 73e1775
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vite/src/node/server/middlewares/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ export function proxyMiddleware(
}
const proxy = httpProxy.createProxyServer(opts) as HttpProxy.Server

proxy.on('error', (err) => {
proxy.on('error', (err, req, res) => {
config.logger.error(`${colors.red(`http proxy error:`)}\n${err.stack}`, {
timestamp: true,
error: err
})
res
.writeHead(500, {
'Content-Type': 'text/plain'
})
.end()
})

if (opts.configure) {
Expand Down

0 comments on commit 73e1775

Please sign in to comment.