httpNodeMiddleware in settings #1686
-
Hey 👋 I am in the middle of evaluating FlowForge With around 5 Node RED Instances. But I have run into a hurdle. One of our legacy systems has broken mime types when POSTing data to Node RED, this is a 3rd party system, and is no longer supported. application/xml -> xml Therefore in Node RED, I add middleware to correct it, before it reaches the HTTP in node, else we get httpNodeMiddleware: function(req, res, next) {
if (req.headers['content-type']) {
const ContentType = req.headers['content-type'];
if (ContentType === 'xml' || ContentType === 'json') {
req.headers['content-type'] = `application/${ContentType}`;
}
}
next();
}, Is there a way to do this in FlowForge? I have recently posted questions on The forums, and didn't want to start spamming it with various questions. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Hi, There isn't currently a way to include user supplied custom middleware with FlowForge. It's not something on our current roadmap, but we can look at if it would make sense (no promises on if/when at this point) Unfortunately I don't think there any other options from a Node-RED point of view as the content-type needs fixing before it gets passed to the parser which is already in the middleware queue. A really hacky/nasty solution would be to point the broken app at a small proxy that can fix the header before forwarding the request to Node-RED. |
Beta Was this translation helpful? Give feedback.
-
Hi @hardillb Thanks for the reply. No worries, but if an opportunity arises to review it - that will be great. I implemented a proxy inside Node RED itself - and it actually runs great (I set the TCP out node as a Reply) This is just a test - but currently is having the affect I need. |
Beta Was this translation helpful? Give feedback.
-
Cool, Just a quick notes, the reason I didn't suggest doing it in NR is because the TCP nodes are only available with the localfs build of FlowForge. They will not work with Docker/Kubernetes because the projects are exposed via a reverse HTTP proxy (hence why we need DNS entries to do virtual host routing) For LocalFS this looks like it will work well, but for the other drivers a little standalone app shouldn't be too hard as I think there are a few node packages that let you build full http proxies with some intercept modification options. I have raised a feature request to cover adding middleware. Ben |
Beta Was this translation helpful? Give feedback.
Hi,
There isn't currently a way to include user supplied custom middleware with FlowForge.
It's not something on our current roadmap, but we can look at if it would make sense (no promises on if/when at this point)
Unfortunately I don't think there any other options from a Node-RED point of view as the content-type needs fixing before it gets passed to the parser which is already in the middleware queue.
A really hacky/nasty solution would be to point the broken app at a small proxy that can fix the header before forwarding the request to Node-RED.