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

Commit 74273da

Browse files
committed
return a 404 for not found api, module and lib routes
1 parent 79ec946 commit 74273da

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

config/lib/express.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ module.exports.initModulesServerRoutes = function (app) {
177177
* Configure error handling
178178
*/
179179
module.exports.initErrorRoutes = function (app) {
180-
// 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.
181180
app.use(function (err, req, res, next) {
182181
// If the error object doesn't exists
183182
if (!err) return next();
@@ -188,12 +187,6 @@ module.exports.initErrorRoutes = function (app) {
188187
// Redirect to error page
189188
res.redirect('/server-error');
190189
});
191-
192-
// Assume 404 since no middleware responded
193-
app.use(function (req, res) {
194-
// Redirect to not found page
195-
res.redirect('/not-found');
196-
});
197190
};
198191

199192
/**

modules/core/server/routes/core.server.routes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ module.exports = function(app) {
66

77
// Define error pages
88
app.route('/server-error').get(core.renderServerError);
9-
app.route('/not-found').get(core.renderNotFound);
9+
10+
// Return a 404 for all undefined api, module or lib routes
11+
app.route('/:url(api|modules|lib)/*').get(core.renderNotFound);
1012

1113
// Define application route
1214
app.route('/*').get(core.renderIndex);

0 commit comments

Comments
 (0)