Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Exposing Local Development Servers to the Internet Using Localtunnel

Tech 1

Localtunnel is a Node.js-based reverse proxy service that enables developers to expose their local development environment to the internet without configuring routers or deploying to external servers. This tool is particularly useful when you need to share your work with others or test webhooks from external services.

Common Use Cases

Remote Development and Debugging When building web applications localy, you might need to demonstrate functionality to remote team members or test how the application behaves on different devices. Localtunnel creates a publicly accessible URL that points to your local development server, allowing anyone with the link to interact with your application.

Mobile Device Testing Testing responsive designs or mobile-specific features often requires accessing the local server from actual mobile devices. By exposing your local environment through Localtunnel, you can open your project on smartphones or tablets connected to different networks.

Temporary Demonstrations During client presentations or technical interviews, you may need to showcase a working application without the overhead of deploying to production servers. Localtunnel provides a quick solution for temporary access that can be terminated instantly.

Implementation Guide

Consider a scenario where you have a Vite-based Svelte application running on your local machine. First, create and set up the project:

npm create vite@latest svelte-demo -- --template svelte
cd svelte-demo
npm install

Build the production version and start the preview server:

npm run build
npm run preview

The preview server typically starts on port 4173. Note this port number for the next step.

To expose this local server to the internet, execute the Localtunnel command with your port:

npx localtunnel --port 4173

The command outputs a randomly generated subdomain (such as https://your-tunnel-name.loca.lt). Opening this URL in a browser prompts for verification.

Verification Process

Localtunnel requires passsword verification using your machine's IP address. To locate your IP, visit the verification page provided in the command output. Enter the IP address in the input field and submit. After a brief connection establishment period, your local application becomes accessible via the public URL.

Share the generated URL with your audience. Be cautious about sharing your IP address with untrusted parties. Alternatively, use a mobile hotspot with cellular data to generate a different IP address for added security.

Persistent Installation

For frequent use, install Localtunnel globally:

npm install -g localtunnel

After global installation, the shorter lt command becomes available:

lt --port 4173

Refer to the official Localtunnel documentation for additional configuration options and advanced features.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.