1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

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

View File

@ -154,6 +154,13 @@ module.exports = function(RED) {
return wrapper; 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) { function HTTPIn(n) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
if (RED.settings.httpNodeRoot !== false) { 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(); } var httpMiddleware = function(req,res,next) { next(); }
if (RED.settings.httpNodeMiddleware) { if (RED.settings.httpNodeMiddleware) {