Node-RED : IBM developerWorks Open Tech Talk

Readers of my blog know I am a huge fan of Node-RED so now you can learn about it in the upcoming tech talk by IBM developerWorks. I most recently used Node-RED in an Eclipse application where I provide an automatic translation service for a tool called PET.

node-redIBM developerWorks Open Tech Talk
Node-RED
Categories: Cloud, Internet of Things

Wed June 22nd, 11 AM ET

Web Meeting link.

Node-RED is a tool for wiring together the Internet of Things in new and interesting ways, including hardware devices, APIs, and online services. Node-RED makes it easy to wire together real-world events, add in some intelligence, and access simple nodes to integrate them with existing messaging systems and social platforms such as Twitter, MongoDB, and Redis to create apps that can react to the world around them..  Learn more.

Advertisements

Allowing CORS from a Node-Red Bluemix application

I wrote a rating application some time ago in Node-Red and have since needed another similar application but with slightly different behavior. So I went ahead and created a new Node-Red application on Bluemix and decided to start from scratch since it was so simple to set up. This application has three requests – Get Rating, Post Rating, and Post Comment. Here is the current flow:

Image (1) rate-flow-680x422.png for post 5391

The problem I had was the requests actually respond with JSON and I could not figure out how to enable CORS!

The first thing I did was in the Image (2) cors.png for post 5391 node I added the following to the response:

Image (3) cors2.png for post 5391

And that did not work. Then, I stumbled upon this in my Cloudant dashboard in the Account Section under CORS:

 

Image (4) cloudant_admin-680x212.png for post 5391

Once I checked all domains it worked fine! I am sure I can restrict the domains appropriately but I guess I don’t understand why the CORS options are under the Cloudant section and not the base application somewhere. I would think this is a specific thing to hitting the Cloudant service directly, not through a Node-Red Node. I am very interested in hearing others opinions on this.

Update:

After using the Cloudant UI to update my profile I went back and checked the bluemix-settings.js saw it indeed added the httpNodeCors line to the profile:

httpNodeCors: { origin: “*”, methods: [‘GET’,’PUT’,’POST’,’DELETE’] },

So this is clearly the issue as I saw a similar question on developerworks but saw no example of the syntax.