diff --git a/packages/node_modules/@node-red/nodes/core/network/21-httpin.js b/packages/node_modules/@node-red/nodes/core/network/21-httpin.js index 34030f13d..0083ad315 100644 --- a/packages/node_modules/@node-red/nodes/core/network/21-httpin.js +++ b/packages/node_modules/@node-red/nodes/core/network/21-httpin.js @@ -16,6 +16,7 @@ module.exports = function(RED) { "use strict"; + var rootApp; var bodyParser = require("body-parser"); var multer = require("multer"); var cookieParser = require("cookie-parser"); @@ -27,7 +28,6 @@ module.exports = function(RED) { var isUtf8 = require('is-utf8'); var hashSum = require("hash-sum"); var PassThrough = require('stream').PassThrough; - var rootApp = getRootApp(RED.httpNode); var rawDataRoutes = new Set(); /** @@ -162,10 +162,12 @@ module.exports = function(RED) { return next(); } - // Add middleware to the stack - rootApp.use(setupRawBodyCapture); - // Move the router to top of the stack - rootApp._router.stack.unshift(rootApp._router.stack.pop()); + if(typeof RED.httpNode === 'function' && (rootApp = getRootApp(RED.httpNode))) { + // Add middleware to the stack + rootApp.use(setupRawBodyCapture); + // Move the router to top of the stack + rootApp._router.stack.unshift(rootApp._router.stack.pop()); + } function createRequestWrapper(node,req) { // This misses a bunch of properties (eg headers). Before we use this function