Search code examples
node.jsibm-cloudnode-red

Disable HTTP client calls for IBM Bluemix Node-RED server API


I am using IBM Bluemix to generate the Node-RED flow. Node-RED code act as the server and client call the Node-RED through API.

Client can call the Bluemix Node-RED server API via both HTTP and HTTPS methods. I need to disable the in-comming HTTP calls.

  1. Is that available any methods to disable in-comming HTTP calls via bluemix.setting or etc.

  2. I used the function node after the HTTP IN node. Checking headers to identify request is HTTP or HTTPS. If it is HTTP, then set the response headers like below.

    msg.res.sendStatus(403).send('HTTP disabled')    
    msg.res.sendStatus(403)    
    msg.res.status(403)
    

in all the time i am getting

Deprecated call to msg.res.sendStatus
Deprecated call to msg.res.status

I would like to how to resolve this issue ?


Solution

    1. to disabled the admin api, you should set httpAdminRoot to false. Alternatively, you can use adminAuth in order to enable access control on the admin api - http://nodered.org/docs/security

    2. In order to respond to an HTTP request received by an HTTP In node, you must set the appropriate properties of the message and pass it to an HTTP Response node. You must not be call functions of msg.res directly - that is deprecated as per the log message you get. The info tab for the HTTP Response node describes what properties you can set, including:

      • payload is sent as the body of the response
      • statusCode, if set, is used as the response status code (default: 200)

    For example, your Function node would do:

    msg.statusCode = 403;
    msg.payload = "HTTP disabled";
    return msg;
    

    and then wire that Function node to an HTTP Response node.