Share your website with others without hosting it on cloud!!!
Ishan Mishra
Posted on April 24, 2021
1. Overview
The method discussed in this article is not an alternative to hosting sites on cloud, its just a temporary way of sharing the website while it is under development phase.
2. Setup
We are going to use localtunnel to expose our localhost to the internet.
- Step-1: Download and Install npm from here. Note: Node installer includes npm.
- Step-2: Install localtunnel using following command
npm install -g localtunnel
Note: You may need to add 'sudo' before npm in linux/mac systems.
This will install localtunnel globally. Read more about localtunnel here.
3. Expose localhost
For demo I am going to use a react based website, and run it on port 3001.
Now the site is running on localhost, next step is to expose this localhost's port to internet, to do this we will run the following command on terminal
npx localtunnel -p 3001
Replace '3001' with the port number your site running on
This command will generate a link, this link can be visited in any device in any location and will redirect to the localhost's port on our localsystem.
Note: We need to keep serving the website on our localsystem's port.
4. Conclusion
Clearly this method is not an alternative to hosting the site on cloud, but can be very helpful for sharing websites/webapps, while they are under development. While setting up OAuth using facebook it requires redirect url with 'https' so localtunnel can be helpfull in this scenario too.
[1]: localtunnel
Posted on April 24, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.