diff --git a/components/server/src/express-util.ts b/components/server/src/express-util.ts index 9b3916ac3d2883..bae9c43a0681aa 100644 --- a/components/server/src/express-util.ts +++ b/components/server/src/express-util.ts @@ -73,7 +73,10 @@ export function unhandledToError(req: express.Request, res: express.Response, ne if (isAnsweredRequest(req, res)) { return next(); } - return next(new Error("unhandled request: " + req.method + " " + req.originalUrl)); + // Instead of throwing an error, send a user-friendly response for unknown routes + console.error("unhandled request: " + req.method + " " + req.originalUrl); + res.status(404).send("Page not found"); + // return next(new Error("unhandled request: " + req.method + " " + req.originalUrl)); } /**