CORS not properly configured on multiple http routes

Fixes #783
This commit is contained in:
Nick O'Leary 2016-01-13 12:54:34 +00:00
parent 6dc640b129
commit 6e75089f3a
1 changed files with 7 additions and 8 deletions

View File

@ -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) {