1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
Steve-Mcl 2023-06-22 09:35:44 +01:00
commit 2fdbe12a7f

View File

@ -302,7 +302,7 @@ httpsPromise.then(function(startupHttps) {
settings.httpNodeAuth = settings.httpNodeAuth || settings.httpAuth; settings.httpNodeAuth = settings.httpNodeAuth || settings.httpAuth;
} }
if(settings.httpStatic) { if (settings.httpStatic) {
settings.httpStaticRoot = formatRoot(settings.httpStaticRoot || "/"); settings.httpStaticRoot = formatRoot(settings.httpStaticRoot || "/");
const statics = Array.isArray(settings.httpStatic) ? settings.httpStatic : [settings.httpStatic]; const statics = Array.isArray(settings.httpStatic) ? settings.httpStatic : [settings.httpStatic];
const sanitised = []; const sanitised = [];
@ -414,13 +414,7 @@ httpsPromise.then(function(startupHttps) {
if (settings.httpNodeRoot !== false) { if (settings.httpNodeRoot !== false) {
app.use(settings.httpNodeRoot,RED.httpNode); app.use(settings.httpNodeRoot,RED.httpNode);
} }
// if (settings.httpStatic) {
// settings.httpStaticAuth = settings.httpStaticAuth || settings.httpAuth;
// if (settings.httpStaticAuth) {
// app.use("/",basicAuthMiddleware(settings.httpStaticAuth.user,settings.httpStaticAuth.pass));
// }
// app.use("/",express.static(settings.httpStatic));
// }
if (settings.httpStatic) { if (settings.httpStatic) {
let appUseMem = {}; let appUseMem = {};
for (let si = 0; si < settings.httpStatic.length; si++) { for (let si = 0; si < settings.httpStatic.length; si++) {
@ -428,6 +422,7 @@ httpsPromise.then(function(startupHttps) {
const filePath = sp.path; const filePath = sp.path;
const thisRoot = sp.root || "/"; const thisRoot = sp.root || "/";
const options = sp.options; const options = sp.options;
const middleware = sp.middleware;
if(appUseMem[filePath + "::" + thisRoot]) { if(appUseMem[filePath + "::" + thisRoot]) {
continue;// this path and root already registered! continue;// this path and root already registered!
} }
@ -435,6 +430,9 @@ httpsPromise.then(function(startupHttps) {
if (settings.httpStaticAuth) { if (settings.httpStaticAuth) {
app.use(thisRoot, basicAuthMiddleware(settings.httpStaticAuth.user, settings.httpStaticAuth.pass)); app.use(thisRoot, basicAuthMiddleware(settings.httpStaticAuth.user, settings.httpStaticAuth.pass));
} }
if (middleware) {
app.use(thisRoot, middleware)
}
app.use(thisRoot, express.static(filePath, options)); app.use(thisRoot, express.static(filePath, options));
} }
} }