From 6e75089f3a9c1204ed392a9138dc7a863a285e47 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 13 Jan 2016 12:54:34 +0000 Subject: [PATCH] CORS not properly configured on multiple http routes Fixes #783 --- nodes/core/io/21-httpin.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/nodes/core/io/21-httpin.js b/nodes/core/io/21-httpin.js index ae549e482..5ec24aec1 100644 --- a/nodes/core/io/21-httpin.js +++ b/nodes/core/io/21-httpin.js @@ -154,6 +154,13 @@ module.exports = function(RED) { return wrapper; } + var corsHandler = function(req,res,next) { next(); } + + if (RED.settings.httpNodeCors) { + corsHandler = cors(RED.settings.httpNodeCors); + RED.httpNode.options("*",corsHandler); + } + function HTTPIn(n) { RED.nodes.createNode(this,n); if (RED.settings.httpNodeRoot !== false) { @@ -185,14 +192,6 @@ module.exports = function(RED) { } }; - var corsHandler = function(req,res,next) { next(); } - - if (RED.settings.httpNodeCors && !corsSetup) { - corsHandler = cors(RED.settings.httpNodeCors); - RED.httpNode.options("*",corsHandler); - corsSetup = true; - } - var httpMiddleware = function(req,res,next) { next(); } if (RED.settings.httpNodeMiddleware) {