Merge pull request #3277 from node-red/debug-path-fix

Add proper error handling for 404 errors when serving debug files
pull/3279/head
Nick O'Leary 2021-12-01 13:48:25 +00:00 committed by GitHub
commit 68a80b9244
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -280,6 +280,18 @@ module.exports = function(RED) {
root: path.join(__dirname,"lib","debug"),
dotfiles: 'deny'
};
res.sendFile(req.params[0], options);
try {
res.sendFile(
req.params[0],
options,
err => {
if (err) {
res.sendStatus(404);
}
}
)
} catch(err) {
res.sendStatus(404);
}
});
};