How to monitor API traffic from a node js app

It is sometimes helpful to see the API traffic that is going on between the Gitana javascript driver and the Cloud CMS API server. This is a non-intrusive method of doing that.

install a tool called Charles Proxy
This is an excellent tool for monitoring http/https traffic.

Once installed, start Charles Proxy and enable reverse proxy:

Check "Enable Reverse Proxies" and then click the "Add" button. A port will be assigned (55703 in the example below). Set Remote Host to "" and Remote Port to 443. Click "OK".

Now edit the gitana.json file used by your Node js application and change the baseURL property to:
"baseURL": "https://localhost:55703"
Use the port that charles proxy assigned to you when you enabled the reverse proxy to

You will probably need to add the following line somewhere in your node js code:
It's probably best to enable this only if you are in dev mode:
if (process.env.NODE_ENV == "dev") {
    process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
Now charles will capture all your traffic. Initally the messages will appear encrypted. To show unencrypted messages right click on the url and select "Enable SSL Proxying":

*Remember to restore baseURL in gitana.json when charles is not running or your node app will not be able to connect and will appear to hang on startup.