From 2b160773ae58d5a1423801a2e6b05770b97d6689 Mon Sep 17 00:00:00 2001 From: Siddhant Khare Date: Wed, 25 Oct 2023 16:18:31 +0000 Subject: [PATCH] fix express unhandled endpoints --- components/server/src/express-util.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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)); } /**