Merge branch 'bugfix/404/#501' of https://github.com/dotch/mean-1 into error-404-pages

This commit is contained in:
Mikael Korpela
2015-05-18 10:45:11 +03:00
2 changed files with 3 additions and 8 deletions

View File

@@ -177,7 +177,6 @@ module.exports.initModulesServerRoutes = function (app) {
* Configure error handling
*/
module.exports.initErrorRoutes = function (app) {
// Assume 'not found' in the error msgs is a 404. this is somewhat silly, but valid, you can do whatever you like, set properties, use instanceof etc.
app.use(function (err, req, res, next) {
// If the error object doesn't exists
if (!err) return next();
@@ -188,12 +187,6 @@ module.exports.initErrorRoutes = function (app) {
// Redirect to error page
res.redirect('/server-error');
});
// Assume 404 since no middleware responded
app.use(function (req, res) {
// Redirect to not found page
res.redirect('/not-found');
});
};
/**

View File

@@ -6,7 +6,9 @@ module.exports = function(app) {
// Define error pages
app.route('/server-error').get(core.renderServerError);
app.route('/not-found').get(core.renderNotFound);
// Return a 404 for all undefined api, module or lib routes
app.route('/:url(api|modules|lib)/*').get(core.renderNotFound);
// Define application route
app.route('/*').get(core.renderIndex);