In this post, we will tell you how you can take the API on your machine to be accessible from WWW by using a powerful and free tool called ngrok.
The Problem
Many times we developers develop APIs for our apps. But when we are working in a team and you need to give access to your API to other team members, you just have one option, upload it to a server. This process is very time-consuming.
The Solution
Wouldn't it be easy to simply take the API from localhost to WWW so that anyone could access it? Well, that's exactly what NGrok does for you.
How does it help?
Suppose, I am developing an API that gives me the list of food items. As I am developing it on my machine, the URL to access this would be
Now, I would like my colleague to access this endpoint. So, to do that, I will use ngrok.
Step 1:
Simply visit https://ngrok.com/ and download the ngrok.
Step 2:
Now before using ngrok you have to first set the auth token. So simply go to the ngrok site and get the auth token by creating the account. Now run the below command with your auth token.
Step 3:
Lastly, just run the below command by specifying the port no on which you want to receive the request from WWW.
In My case, it is 80 because my xampp is running on port 80.
Result
Now you will get a random WWW URL from NGROK.
By using this URL anyone can access your localhost API.
Thank you for reading!
Follow us on Instagram
https://www.instagram.com/the.ninja.programmer/
Top comments (3)
Thanks for reminding us of Ngrok!
This method is known as port tunneling, and Ngrok is just one service. There are plenty more better alternatives to Ngrok. You can check them here.
Great! Maybe include some detailed Code as well, they are great!