mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Fix condition check for RED.httpNode to ensure proper middleware setup
This commit is contained in:
parent
caeb5d3538
commit
bb43d63b54
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
module.exports = function(RED) {
|
module.exports = function(RED) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
var rootApp;
|
||||||
var bodyParser = require("body-parser");
|
var bodyParser = require("body-parser");
|
||||||
var multer = require("multer");
|
var multer = require("multer");
|
||||||
var cookieParser = require("cookie-parser");
|
var cookieParser = require("cookie-parser");
|
||||||
@ -27,7 +28,6 @@ module.exports = function(RED) {
|
|||||||
var isUtf8 = require('is-utf8');
|
var isUtf8 = require('is-utf8');
|
||||||
var hashSum = require("hash-sum");
|
var hashSum = require("hash-sum");
|
||||||
var PassThrough = require('stream').PassThrough;
|
var PassThrough = require('stream').PassThrough;
|
||||||
var rootApp = getRootApp(RED.httpNode);
|
|
||||||
var rawDataRoutes = new Set();
|
var rawDataRoutes = new Set();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,10 +162,12 @@ module.exports = function(RED) {
|
|||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add middleware to the stack
|
if(typeof RED.httpNode === 'function' && (rootApp = getRootApp(RED.httpNode))) {
|
||||||
rootApp.use(setupRawBodyCapture);
|
// Add middleware to the stack
|
||||||
// Move the router to top of the stack
|
rootApp.use(setupRawBodyCapture);
|
||||||
rootApp._router.stack.unshift(rootApp._router.stack.pop());
|
// Move the router to top of the stack
|
||||||
|
rootApp._router.stack.unshift(rootApp._router.stack.pop());
|
||||||
|
}
|
||||||
|
|
||||||
function createRequestWrapper(node,req) {
|
function createRequestWrapper(node,req) {
|
||||||
// This misses a bunch of properties (eg headers). Before we use this function
|
// This misses a bunch of properties (eg headers). Before we use this function
|
||||||
|
Loading…
x
Reference in New Issue
Block a user