Search code examples
ibm-cloudnode-redibm-watson

Call Bluemix service from outside app


I've built a simple translate service with Node-Red and Watson. The service is ok when called directly from the browser but I have an error ( CORS ) when call the service via http from my Angular app.

Does Bluemix allow CORS ?

Thanks in advance.


Solution

  • add these code lines in your bluemix-settings.js and repush your app

    // The following property can be used to configure cross-origin resource sharing
        // in the HTTP nodes.
        // See https://github.com/troygoode/node-cors#configuration-options for
        // details on its contents. The following is a basic permissive set of options:
       httpNodeCors: {
          origin: "*",
         methods: "GET,PUT,POST,DELETE"
        },
    

    Add this code after " functionGlobalContext: { }, "