Google News
logo
Express.js - Interview Questions
How to Redirect 404 Errors to A Page In Express.js?
In server.js add the subsequent code to send 404 errors back to a page in our ExpressJS App :
/* Define fallback route */
app.use(function(req, res, next) {
res.status(404).json({errorCode: 404, errorMsg: "route not found"});
});
Advertisement