From 8ff84fd782ead8891d47702312bd45843ca1aa86 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 13 Oct 2023 00:07:57 +0200 Subject: [PATCH] change image links from public to local (#5) * change image links from public to local Apply https://github.com/endemecio02/node-red-contrib-httpauth/pull/3 from @sakazuki * Fix path join * Use Express built-in methods * Minor syntax --- nodes/http-auth.html | 2 +- nodes/http-auth.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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..e820737 100644 --- a/nodes/http-auth.js +++ b/nodes/http-auth.js @@ -99,4 +99,20 @@ module.exports = function (RED) { } RED.nodes.registerType('http-basic-auth', HttpAuthNode); + + if (RED.httpAdmin) { + const path = require('path'); + RED.httpAdmin.get('/node-red-http-basic-auth/images/:name', (req, res, next) => { + const options = { + root: path.join(__dirname, '..', 'images'), + dotfiles: 'deny', + }; + const fileName = req.params.name; + res.sendFile(fileName, options, (err) => { + if (err) { + next(err); + } + }); + }); + } };