diff --git a/packages/node_modules/node-red/red.js b/packages/node_modules/node-red/red.js index 72f8a4169..5bb81e8bd 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) @@ -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)); } } 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 } }, - + }, /*******************************************************************************