fix(errors): dedicated 404 errors

This commit is contained in:
Benedikt Rötsch
2018-02-14 10:25:01 +01:00
committed by Benedikt Rötsch
parent 9ca77e4e9c
commit 4cdfea0b3e
5 changed files with 40 additions and 21 deletions

4
app.js
View File

@@ -37,7 +37,7 @@ app.use(express.static(path.join(__dirname, 'public')))
// Force all requests on production to be served over https
app.use(function (req, res, next) {
if (req.headers['x-forwarded-proto'] !== 'https' && process.env.NODE_ENV === 'production') {
var secureUrl = 'https://' + req.hostname + req.originalUrl
const secureUrl = 'https://' + req.hostname + req.originalUrl
res.redirect(302, secureUrl)
}
next()
@@ -132,7 +132,7 @@ app.use('/', routes)
// Catch 404 and forward to error handler
app.use(function (request, response, next) {
var err = new Error('Not Found')
const err = new Error(translate('error404Route', response.currentLocale))
err.status = 404
next(err)
})