diff --git a/nodes/http-auth.html b/nodes/http-auth.html index 1cb2bdd..cfa545b 100644 --- a/nodes/http-auth.html +++ b/nodes/http-auth.html @@ -71,7 +71,7 @@

- +

Config

diff --git a/nodes/http-auth.js b/nodes/http-auth.js index e8db485..ff3445a 100644 --- a/nodes/http-auth.js +++ b/nodes/http-auth.js @@ -99,4 +99,25 @@ module.exports = function (RED) { } RED.nodes.registerType('http-basic-auth', HttpAuthNode); + + if (RED.httpAdmin) { + const fs = require('fs'); + const path = require('path'); + RED.httpAdmin.get('/node-red-http-basic-auth/images/:file', function (req, res, next) { + const filename = req.params.file.replace(/[^a-zA-Z0-9._-]/g, '').replace(/^\.+/g, ''); + fs.readFile(path.join(__dirname, '/../images/', filename), function (err, data) { + if (err) { + res.status(404).end(); + } else { + res.set('Content-Type', 'image/png'); + res.send(data, function (err) { + if (err) { + console.warn('Error serving image:', err); + res.status(500).end(); + } + }); + } + }); + }); + } };