Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Merge branch 'bugfix/404/#501' of https://github.com/dotch/mean-1 int…
Browse files Browse the repository at this point in the history
…o error-404-pages
  • Loading branch information
simison committed May 18, 2015
2 parents f24ce65 + 74273da commit 8190ee4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
7 changes: 0 additions & 7 deletions config/lib/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');
});
};

/**
Expand Down
4 changes: 3 additions & 1 deletion modules/core/server/routes/core.server.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8190ee4

Please sign in to comment.