Skip to content

nkapp expose

Ephemerally expose a service to the local area network (LAN) or globally via a public tunnel. Ideal for testing on mobile devices, sharing with teammates, or webhook debugging.

bash
nkapp expose <service> [options]

Arguments

ArgumentTypeDescription
servicestringRequired. Name of the service to expose.

Options

FlagTypeDefaultDescription
-e, --env <env>stringlocalTarget environment
-i, --ip <address>stringauto-detectManual LAN IP override
-p, --port <port>number8080Gateway port to use for LAN exposure
-t, --tunnelbooleanfalseEnable global exposure via localtunnel

How It Works

LAN Exposure (Default)

Nanokit detects your LAN IP address and configures the Caddy gateway to serve the target service on a LAN-accessible port. Multiple URL formats are provided:

http://web.my-app.192.168.1.50.nip.io:8080  (Primary LAN hostname)
http://web.my-app.192.168.1.50.sslip.io:8080 (Secondary LAN hostname)
http://192.168.1.50:8080                      (Direct LAN IP)

Global Tunnel (--tunnel)

When the -t flag is passed, Nanokit spawns a localtunnel process to create a publicly reachable URL:

https://abc123.loca.lt  (Global - Working Everywhere)

The CLI process stays alive to maintain the tunnel connection.


IP Detection

Nanokit uses a smart scoring algorithm to detect the best LAN IP:

  • Prioritizes physical interfaces (en0, eth0, wlan0) over virtual bridges
  • Filters out Docker, VPN, and loopback interfaces
  • Prefers 192.168.x.x over 10.x.x.x ranges
  • WSL2 Aware: Automatically queries the Windows host IP via PowerShell

WSL2 Notes

When running in WSL2, LAN access requires a Windows port proxy:

powershell
# Run in PowerShell (Admin)
netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=8080 connectaddress=<WSL_IP>

Nanokit prints this command automatically when WSL is detected.


Examples

bash
# Expose web service on LAN
nkapp expose web

# Expose with a specific port
nkapp expose api -p 9090

# Expose globally via tunnel
nkapp expose web --tunnel

# Manually specify LAN IP
nkapp expose web --ip 192.168.1.100

Note. LAN exposure is ephemeral — it will be reset on the next full nkapp up reconciliation.