Skip to content

Commit

Permalink
change image links from public to local
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkarex committed Oct 12, 2023
1 parent b871d24 commit c3acf81
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nodes/http-auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</p>

<p>
<img src="https://raw.githubusercontent.com/alexandrainst/node-red-http-basic-auth/main/images/flow.png" />
<img src="node-red-http-basic-auth/images/flow.png" />
<p>

<h2>Config</h2>
Expand Down
21 changes: 21 additions & 0 deletions nodes/http-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
}
});
});
}
};

0 comments on commit c3acf81

Please sign in to comment.