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

Enabling CORS for WebSphere Commerce REST

Commerce-CORSI have two servers, one application server (JSP based) and one WebSphere Commerce server. I want to be able to call the REST API’s on the Commerce server via JavaScript served up by the application server. So my JavaScript would look like this:

$.ajax({
      url: myCommerceServerRestURL,
      method: "GET",
      crossDomain: true,
      contentType: "application/json",
      dataType: "json"
 })

The problem is, if CORS is not enabled on the WebSphere Commerce server you will receive the infamous No ‘Access-Control-Allow-Origin’ header is present on the requested resource. And the call fails.

Now WebSphere Commerce can be a little tricky if your server has a web server in front of it. You essentially have to enable it in both places – or at least that is what I had to do. If I only had to do one of these please let me know – I got tired of testing the different tips from the netverse.

I have IHS in front of WebSphere Commerce, so, after hours of playing around with different configurations I came up with these steps:

First configure httpd.conf in the IHS/conf directory and add these lines  if you want all domains to be able to access your data:

 <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
        Header set Access-Control-Allow-Methods "GET, PUT, OPTIONS"
        Header set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
 </IfModule>

Remember, you can always override the Access-Control-Origin with a domain or multiple domains to prevent access for everyone.

Next, you have to update the WebSphere Commerce server. You can actually see the Commerce Insights enabling documentation for this (my colleague pointed me to this, thanks J).  You will be editing the WC configuration file and the WC Search configuration file.

 <_config:configgrouping name="HttpSecuritySettings_Rest">
          <_config:property name="CORSAccessControlAllowOrigin" value="*"/>
          <_config:property name="CORSAccessControlAllowMethods" value="GET, HEAD, POST, OPTIONS, PUT, DELETE"/>
          <_config:property name="CORSAccessControlAllowCredentials" value="true"/>
          <_config:property name="CORSAccessControlAllowHeaders" value="Origin,X-Requested-With,Content-Type,Accept,Authorization,cache-control,expires,pragma,wclogonid,wctoken,wctrustedtoken,wcuserid,X-RequestId"/>
          <_config:property name="CORSAccessControlExposeHeaders" value="Access-Control-Allow-Headers"/>
          <_config:property name="CORSAccessControlMaxAge" value="3600"/> 
 </_config:configgrouping>

 

If you found this useful follow this site! I also have a YouTube channel for IBM Commerce.

My first reaction to the React JavaScript Library

ReactOk, I may be a little late to the game but recently I have been studying up on Facebooks/Instagrams React JavaScript library and I have to say I am fairly impressed with it. They say it is the V in MVC (model view controller). Outside of the fact that React applications can run both locally and on the server via Node (which I am sure you know I am a big fan of Node) it also comes with a React Native library!

React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about — learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native. – link

This means you can now truly “learn once and run everywhere”.  The great news is you can start coding now on BlueMix. Check out this article to see how React Native can be developed and deployed on BlueMix. If you are doing a cool project using React or React Native send me a link to your post, I would like to check it out.