mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
add httpStaticMiddleware before serve static files
This commit is contained in:
parent
6179d1eef2
commit
8d06be81d8
7
packages/node_modules/node-red/red.js
vendored
7
packages/node_modules/node-red/red.js
vendored
@ -423,6 +423,11 @@ httpsPromise.then(function(startupHttps) {
|
||||
// }
|
||||
if (settings.httpStatic) {
|
||||
let appUseMem = {};
|
||||
let httpStaticMiddleware = (req, res, next) => next()
|
||||
if (typeof settings.httpStaticMiddleware === 'function' || isArray(settings.httpStaticMiddleware)) {
|
||||
httpStaticMiddleware = settings.httpStaticMiddleware
|
||||
}
|
||||
|
||||
for (let si = 0; si < settings.httpStatic.length; si++) {
|
||||
const sp = settings.httpStatic[si];
|
||||
const filePath = sp.path;
|
||||
@ -434,7 +439,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, httpStaticMiddleware, express.static(filePath));
|
||||
}
|
||||
}
|
||||
|
||||
|
12
packages/node_modules/node-red/settings.js
vendored
12
packages/node_modules/node-red/settings.js
vendored
@ -239,6 +239,18 @@ module.exports = {
|
||||
*/
|
||||
//httpStaticRoot: '/static/',
|
||||
|
||||
/** The following property can be used to add a custom middleware function
|
||||
* in front of all static files. This allows custom authentication to be
|
||||
* applied to all http in nodes, or any other sort of common request processing.
|
||||
* It can be a single function or an array of middleware functions.
|
||||
*/
|
||||
// httpStaticMiddleware: [
|
||||
// require('compression')({ threshold: 0}),
|
||||
// function(req,res,next) {
|
||||
// // for example
|
||||
// next();
|
||||
// },
|
||||
// ],
|
||||
/*******************************************************************************
|
||||
* Runtime Settings
|
||||
* - lang
|
||||
|
Loading…
x
Reference in New Issue
Block a user