mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
handle 404 errors better
+ get rid of fs.exists
This commit is contained in:
parent
100430227c
commit
7687965219
2 changed files with 7 additions and 4 deletions
|
@ -45,11 +45,11 @@ module.exports = function(config, auth, storage) {
|
|||
// Static
|
||||
app.get('/-/static/:filename', function(req, res, next) {
|
||||
var file = __dirname + '/static/' + req.params.filename
|
||||
fs.exists(file, function(exists) {
|
||||
if (exists) {
|
||||
res.sendfile(file)
|
||||
res.sendfile(file, function(err) {
|
||||
if (err.status === 404) {
|
||||
next()
|
||||
} else {
|
||||
next( Error[404]('File Not Found') )
|
||||
next(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -415,6 +415,9 @@ module.exports = function(config_hash) {
|
|||
res.report_error(err)
|
||||
})
|
||||
|
||||
app.get('/*', function(req, res, next) {
|
||||
next( Error[404]('file not found') )
|
||||
})
|
||||
|
||||
return app
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue