[feature request] middleware integration

I would like to add the feature that will allow the middleware(s) configured in settings.js for httpAdminMiddleware and ui.middleware to allow for an array of functions instead of just a single function.

This will make it easier to use various 3rd party middlewares, with a simple example being cookie-parser. This will allow for a middleware configuration as:

httpAdminMiddleware: [
  (req, res, next) => {
    // act upon the retrieved cookies
    if (req.signedCookies.mycookie === 'some_value') {
      return next();

   next(new Error('access denied'));

If there are no objections, I will make the pull requests. It is a simple matter of adding
|| Array.isArray(middleware)

1 Like

Hi @kevinGodell

seems reasonable. It would be good to update for httpNodeMiddleware as well - handled in packages/node_modules/@node-red/nodes/core/network/21-httpin.js

Please target the dev branch when you come to doing the PR - that's the new feature development for 1.3.


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.