mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add support for httpStatic middleware
This commit is contained in:
parent
2571949e90
commit
33899763ef
14
packages/node_modules/node-red/red.js
vendored
14
packages/node_modules/node-red/red.js
vendored
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user