From 889489e33ecd70400c3a3b3b970d2ae6666d3c3f Mon Sep 17 00:00:00 2001 From: Kevin Godell Date: Mon, 20 Mar 2023 16:32:14 -0500 Subject: [PATCH 1/3] set default when root is not defined --- packages/node_modules/node-red/red.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/node-red/red.js b/packages/node_modules/node-red/red.js index 2f5ab354c..22b1eb224 100755 --- a/packages/node_modules/node-red/red.js +++ b/packages/node_modules/node-red/red.js @@ -316,10 +316,10 @@ httpsPromise.then(function(startupHttps) { } else { continue; } - sp.subRoot = formatRoot(sp.root); + sp.subRoot = formatRoot(sp.root || "/"); sp.root = formatRoot(path.posix.join(settings.httpStaticRoot,sp.subRoot)); } - settings.httpStatic = sanitised.length ? sanitised : false; + settings.httpStatic = sanitised.length ? sanitised : false; } // if we got a port from command line, use it (even if 0) From 54b2215164ce2e4c6584021ed4f64ac60e2275d4 Mon Sep 17 00:00:00 2001 From: Kevin Godell Date: Mon, 20 Mar 2023 17:31:10 -0500 Subject: [PATCH 2/3] pass options to express.static --- packages/node_modules/node-red/red.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/node_modules/node-red/red.js b/packages/node_modules/node-red/red.js index 22b1eb224..d148dd73b 100755 --- a/packages/node_modules/node-red/red.js +++ b/packages/node_modules/node-red/red.js @@ -427,6 +427,7 @@ httpsPromise.then(function(startupHttps) { const sp = settings.httpStatic[si]; const filePath = sp.path; const thisRoot = sp.root || "/"; + const options = sp.options; if(appUseMem[filePath + "::" + thisRoot]) { continue;// this path and root already registered! } @@ -434,7 +435,7 @@ httpsPromise.then(function(startupHttps) { if (settings.httpStaticAuth) { app.use(thisRoot, basicAuthMiddleware(settings.httpStaticAuth.user, settings.httpStaticAuth.pass)); } - app.use(thisRoot, express.static(filePath)); + app.use(thisRoot, express.static(filePath, options)); } } From 7ae3e32abd11251182cca3b69164c1dd07552b4f Mon Sep 17 00:00:00 2001 From: Kevin Godell Date: Mon, 20 Mar 2023 17:34:12 -0500 Subject: [PATCH 3/3] update example and document feature for httpStatic options --- packages/node_modules/node-red/settings.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/node-red/settings.js b/packages/node_modules/node-red/settings.js index ef76f8680..218baa92d 100644 --- a/packages/node_modules/node-red/settings.js +++ b/packages/node_modules/node-red/settings.js @@ -223,10 +223,15 @@ module.exports = { * to move httpAdminRoot */ //httpStatic: '/home/nol/node-red-static/', //single static source - /* OR multiple static sources can be created using an array of objects... */ + /** + * OR multiple static sources can be created using an array of objects... + * Each object can also contain an options object for further configuration. + * See https://expressjs.com/en/api.html#express.static for available options. + */ //httpStatic: [ // {path: '/home/nol/pics/', root: "/img/"}, // {path: '/home/nol/reports/', root: "/doc/"}, + // {path: '/home/nol/videos/', root: "/vid/", options: {maxAge: '1d'}} //], /** @@ -431,7 +436,7 @@ module.exports = { enabled: true } }, - + }, /*******************************************************************************