diff --git a/packages/node_modules/@node-red/nodes/core/network/21-httpin.js b/packages/node_modules/@node-red/nodes/core/network/21-httpin.js index 1034012ec..1986970a1 100644 --- a/packages/node_modules/@node-red/nodes/core/network/21-httpin.js +++ b/packages/node_modules/@node-red/nodes/core/network/21-httpin.js @@ -171,17 +171,18 @@ module.exports = function(RED) { if (RED.settings.httpNodeCors) { corsHandler = cors(RED.settings.httpNodeCors); - RED.httpNode.options("*", function(req,res,next) { - //see if any routes for this path exist & call next() otherwise call corsHandler - const routes = RED.httpNode._router.stack.filter(e => e.route && e.route.path == req.path && e.route.methods.options === true); - if(routes.length > 0) { - next(); - return - } - corsHandler(req,res,next); - }); } + RED.httpNode.options("*", function(req,res,next) { + //see if any routes for this path exist & call next() otherwise call corsHandler + const routes = RED.httpNode._router.stack.filter(e => e.route && e.route.path == req.path && e.route.methods.options === true); + if(routes.length > 0) { + next(); + return + } + corsHandler(req,res,next); + }); + function HTTPIn(n) { RED.nodes.createNode(this,n); if (RED.settings.httpNodeRoot !== false) { @@ -278,6 +279,8 @@ module.exports = function(RED) { RED.httpNode.patch(this.url,cookieParser(),httpMiddleware,corsHandler,metricsHandler,jsonParser,urlencParser,rawBodyParser,this.callback,this.errorHandler); } else if (this.method == "delete") { RED.httpNode.delete(this.url,cookieParser(),httpMiddleware,corsHandler,metricsHandler,jsonParser,urlencParser,rawBodyParser,this.callback,this.errorHandler); + } else if (this.method == "options") { // https://httpwg.org/specs/rfc7231.html#rfc.section.4.3.7 + RED.httpNode.options(this.url,cookieParser(),httpMiddleware,metricsHandler,jsonParser,urlencParser,rawBodyParser,this.callback,this.errorHandler); } else if (this.method == "trace") { // https://httpwg.org/specs/rfc7231.html#rfc.section.4.3.8 RED.httpNode.trace(this.url,cookieParser(),httpMiddleware,corsHandler,metricsHandler,this.callback,this.errorHandler); }