npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

port2port

v1.0.6

Published

A simple terminal-based reverse proxy server for development that allows dynamic path-to-port mapping.

Downloads

29

Readme


⚡ port2port

🧭 A flexible, terminal-based reverse proxy server for local development. Now with Subdomain Support! Dynamically map subdomains & URL paths to local ports or external URLs, rewrite routes, and manage it all from the terminal or config file.

port2port


✨ Features

  • 🔗 Dynamic proxy routing (/v2>6000, /api>3001, /v2/app>6000/api)
  • 🌐 Subdomain Support (@aif>3032, @pms>/pms>3022)
  • 📁 Config file support (port2port.json or via -f flag)
  • 🧠 Longest prefix match routing (e.g., /v2/beta overrides /v2)
  • 🔃 Path rewrite support (/v2>6000/api rewrites /v2/api)
  • 🖥️ Interactive CLI prompt for adding mappings on the fly
  • 📊 Live-updating table with subdomain & path mappings
  • 🧪 WebSocket (ws) support
  • HTTPS support (ignores invalid SSL certs)
  • 🛠️ Helpful CLI flags: -h, -v, and -f
  • 💻 Localhost only, perfect for dev environments

📦 Installation

npm install -g port2port

🛠️ Usage

Start the proxy server

port2port

You’ll be prompted for a host port (default 4000).


Interactive CLI (On-the-fly Mappings)

Basic Usage

  • Map / to a port:

    5000
  • Map a path to a port:

    /v2>5000
  • Path with rewrite:

    /v2/app>6000/api

Subdomain Usage

  • Map a subdomain root to a port:

    @aif>3032

    http://aif.localhost:4000

  • Map a subdomain path with rewrite:

    @pms>/pms>3022/api

    http://pms.localhost:4000/pms/login

  • Map a subdomain directly to an external URL:

    @external>https://api.example.com/v1

📁 Config File Support

Auto-load from port2port.json

{
  "port": 5000,
  "mappings": {
    "@mf": {
      "/": { "port": 3000, "description": "http://mf.localhost:5000" },
      "/mutualfund": { "port": 3001, "rewrite": "/mutualfund" },
      "/api": { "port": 3001, "rewrite": "/api" }
    },
    "@pms": {
      "/": { "port": 3021 },
      "/pms": { "port": 3022, "rewrite": "/pms" },
      "/api": { "port": 3022, "rewrite": "/api" }
    },
    "/": 4000
  }
}

Custom File

port2port -f my-mappings.json

🔁 Example Output (With Subdomains)

⚙️ Proxy server running at: http://localhost:5000

🔁 Current Path Mappings:
┌─────────┬────────────┬───────────────┬───────────────────────────────────────────────┬──────────────────────────────────────────────┬────────┐
│ (index) │ Subdomain  │ Path          │ → Proxy To                                    │ Description                                  │ Status │
├─────────┼────────────┼───────────────┼───────────────────────────────────────────────┼──────────────────────────────────────────────┼────────┤
│ 0       │ mf         │ /mutualfund   │ http://localhost:3001 (rewrite: /mutualfund)  │ http://mf.localhost:5000/mutualfund/login    │ ✅     │
│ 1       │ aif        │ /aif          │ http://localhost:3032 (rewrite: /aif)         │ http://aif.localhost:5000/aif/login          │ ✅     │
│ 2       │ pms        │ /pms          │ http://localhost:3022 (rewrite: /pms)         │ http://pms.localhost:5000/pms/login          │ ⚪️     │
└─────────┴────────────┴───────────────┴───────────────────────────────────────────────┴──────────────────────────────────────────────┴────────┘

🧰 CLI Flags

| Flag | Description | | --------- | ------------------------------------- | | -h | Show help / usage | | -v | Show version | | -f FILE | Load mappings from a JSON config file |


🧪 Tips

  • Subdomains are accessible via http://<subdomain>.localhost:<host-port>
  • Longest path match ensures precise routing.
  • Supports HTTPS & WebSockets.

🧑‍💻 Ideal For

  • Running multiple projects locally on different subdomains.
  • Testing microservices with clean URL separation.
  • Switching between local & external APIs seamlessly.

📄 License

MIT © 2025