Skip to content

Commit

Permalink
feat(server): return 404 code when xxx.hot-update.json file not found (
Browse files Browse the repository at this point in the history
…#1899)

Co-authored-by: neverland <[email protected]>
  • Loading branch information
9aoy and chenjiahan authored Mar 20, 2024
1 parent 91527fa commit 75d31fe
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/core/src/server/getDevMiddlewares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ const applyDefaultMiddlewares = async ({
upgradeEvents.push(
compileMiddlewareAPI.onUpgrade.bind(compileMiddlewareAPI),
);

middlewares.push((req, res, next) => {
// [prevFullHash].hot-update.json will 404 (expected) when rsbuild restart and some file changed
if (req.url?.endsWith('.hot-update.json')) {
res.statusCode = 404;
res.end();
} else {
next();
}
});
}

if (dev.publicDir !== false && dev.publicDir?.name) {
Expand Down

0 comments on commit 75d31fe

Please sign in to comment.