Skip to content

Commit

Permalink
fix express unhandled endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddhant-K-code committed Oct 25, 2023
1 parent ae38d86 commit 2b16077
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/server/src/express-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit 2b16077

Please sign in to comment.