From 04ffa06221150910fc005fdbd25932778db9f309 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 26 Nov 2021 11:30:51 +0000 Subject: [PATCH] Add proper error handling for 404 errors when serving debug files --- .../@node-red/nodes/core/common/21-debug.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/nodes/core/common/21-debug.js b/packages/node_modules/@node-red/nodes/core/common/21-debug.js index 8d2121580..73d364e43 100644 --- a/packages/node_modules/@node-red/nodes/core/common/21-debug.js +++ b/packages/node_modules/@node-red/nodes/core/common/21-debug.js @@ -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); + } }); };