API Builder

Arrow Builder Debugging Tip – ngrok Secure Tunnel to localhost

During the development of Arrow Builder APIs, you are often running and debugging your Arrow Builder project locally on your machine prior to publishing. This development flow makes it convenient for debugging, as you have immediate and instantaneous access to console logging.

However, accessing your APIs from a local mobile device or a remote mobile device or computer is often difficult and insecure and involves opening ports on your firewall and forwarding incoming traffic to your machine’s IP addresses. Alternatively, you can publish your Arrow app to the cloud, but that is a time consuming process to do repeatedly.

In a previous post, I described how Cloud9 can be used to address this issue. Now, we’ll look at another approach.

I’ve been using a great service – called ngrok – which creates a secure tunnel to localhost without modifying your network. It’s very easy to set up and use, and the free tier is sufficient for most uses.

This blog post describes how to use ngrok with Arrow.

Install ngrok

  1. Go to the ngrok web site and create a free account
  2. Click the download button and follow the install instructions

Start ngrok

  1. Install your token from terminal using:
    
    ./ngrok authtoken <YOUR TOKEN FROM THE DASHBOARD PAGE>
    
  2. Start ngrok from the terminal using:
    
    ./ngrok http 8080
    

    Note: make sure you use the same port that your Arrow app is running on locally

  3. You will see something similar to below. Note the publicly accessible IP address (https://c5ff4678.ngrok.io and https://c5ff4678.ngrok.io) both of which will route to localhost:8080

    Arrow Builder Debugging Tip

    Note: if you stop ngrok and restart it, the IP address will change, so be careful

  4. You can now access your locally running Arrow API using the ngrok URL which is publicly accessible, for example:
    
    https://c5ff4678.ngrok.io/api/appc.mysql/table1
    
  5. You can track your ngrok requests in the browser on localhost, port 4040 as follows:
    
    https://localhost:4040
    

    Arrow Builder Debugging Tip

  6. You can now use the ngrok url in your mobile app and provide this url to anyone needing to test your API while you are still running the Arrow project locally.