Default route(404) is now Content-Type aware(json)

- Cleanup
This commit is contained in:
2023-05-15 02:08:43 +02:00
parent 9c4eb3200e
commit b1a73ebd4a
2 changed files with 7 additions and 6 deletions

View File

@ -13,9 +13,13 @@ Router.use('/api', api_routes);
Router.use('/', frontend_routes);
// Default route.
Router.get('*', function (req, res) {
Router.all('*', function (req, res) {
// TODO: Respond based on content-type (with req.is('application/json'))
res.status(404).render(__path + '/src/frontend/errors/404.eta.html', { url: req.originalUrl });
if (req.is('application/json')) {
res.status(404).json({ errorcode: '404' });
} else {
res.status(404).render(__path + '/src/frontend/errors/404.eta.html', { url: req.originalUrl });
}
});
export default Router;