DEV Community

Muhammad Xudoynazarov
Muhammad Xudoynazarov

Posted on

I Wanted a Simpler Way to Share Localhost, So I Built One

I've been working on something called GoPort, and I wanted to share it here.

Sometimes you just need to show someone what you're working on locally. Maybe you're building a website, testing an API, or trying to get a webhook working.

But localhost is only accessible from your own machine, and deploying an entire project just to test something doesn't always make sense.

There are already tools that solve this problem, but I wanted to try building my own. I also wanted to understand how tunneling works behind the scenes.

So I started working on GoPort.

The idea is pretty simple

GoPort lets you turn your localhost into a public HTTPS URL using a CLI command.

For example, if your app is running on port 8080, you can just run:

goport http 8080
Enter fullscreen mode Exit fullscreen mode

And get a link like:

https://abc123.goport.uz
Enter fullscreen mode Exit fullscreen mode

Now you can share that URL with someone, and they'll be able to access the application running on your computer.

You don't need to configure port forwarding, get a public IP, or deploy anything.

How it works

This is probably the part I enjoyed working on the most.

Instead of opening a port on your router, the GoPort CLI connects to a remote server and keeps that connection open.

When someone visits your public URL, the request goes to the GoPort server first.

The server then forwards it through the tunnel to the CLI running on your machine. The CLI sends the request to your local app and passes the response back.

I'm using yamux to handle multiple streams over the same connection.

That way, multiple HTTP requests can travel through one connection between the CLI and the server.

I also added WebSocket support, since a lot of modern web applications depend on it.

Something else I wanted to add

When you're testing webhooks or APIs, just getting a public URL isn't always enough.

Sometimes you need to see exactly what requests are arriving.

So I added a local request inspector.

While the tunnel is running, you can open:

http://127.0.0.1:4040

From there, you can see incoming requests and responses, replay requests, and copy them as cURL commands.

It's especially useful when you're trying to debug a webhook and can't figure out what the external service is sending.

You can also self-host it

Another thing I wanted was the option to run the tunnel infrastructure myself.

GoPort is open-source under the MIT license, and you can self-host the server instead of using the hosted service.

The project is written mainly in Go, with PocketBase used for the backend and Next.js for the website and dashboard.

Where it's at now

GoPort is already available for Windows, macOS, and Linux.

I've also added things like automatic reconnection and reusable tunnel URLs, so you don't have to start from scratch every time your connection drops.

There's still more I want to work on, but I thought it was a good time to share what I've built.

I'd be interested to hear what other developers think, especially anyone who's worked on tunneling, networking, or similar tools.

And if you try it, let me know if something doesn't work or if the setup could be easier.

GitHub: https://github.com/muhammad-deve/GoPort

Website: https://goport.uz

Thanks for reading!

Top comments (0)