--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With');
// intercept OPTIONS method
if ('OPTIONS' == req.method) {
res.send(200);
}
else {
next();
}
};
app.use(allowCrossDomain);
Then inserted in red.js after "var flowFile;"I am trying to get "Access-Control-Allow-Orign" in the header for the OPTIONS request.I can add this to the header of the response: msg.res.set( "Access-Control-Allow-Origin" , "*");but this is after the browser has failed to get the flag from OPTIONS phase.That is, what I see is that the request never makes from the "Http In" node to my function node where I set the header.Is there a straightforward way to allow Cross Origin Resource Sharing with Node red?
I'll look at this properly later, but we don't want to apply it to * ... that would allow cross domain access to the admin endpoints, which is a different requirement and should be treated separately. Instead, this should only apply to OPTION requests made to end points explicitly created by the http request node.
N