vkma.devRU

The vkma-tunnel CLI: commands and flags

On this page

vkma-tunnel starts a tunnel from the terminal. The CLI works with any local server: Vite without the plugin, vite preview, a server on Express. No install is needed, the package runs through npx.

Running

npx @vkma.dev/tunnel                        # expose http://localhost:5173
npx @vkma.dev/tunnel --provider cloudflared # a one-time URL, no account

With the package installed the command is shorter, and the flags are the same:

npm install -D @vkma.dev/tunnel
pnpm add -D @vkma.dev/tunnel
yarn add -D @vkma.dev/tunnel
bun add -D @vkma.dev/tunnel
vkma-tunnel --port 3000 --host 127.0.0.1 --opentunnel-route mobile --qr

Ctrl+C stops the tunnel.

Commands

Command What it does
vkma-tunnel [run] [flags] starts the tunnel and prints its URL, Ctrl+C stops it
vkma-tunnel reset [--profile name] [--all] deletes stored identities, and their URLs stop working
vkma-tunnel list [--json] shows stored profiles, their URLs and the addresses of the local servers
vkma-tunnel status [profile] [--json] shows the stored identity and the result of probing the local server and the URL

Without a subcommand run is executed. There are also help and version.

Flags

Flag Meaning
--provider <name> the provider: opentunnel (default) or cloudflared
--port <1-65535> the local port, 5173 by default
--host <addr> the local host, localhost by default
--profile <name> the identity profile, by default the project directory name
--config <path> an explicit config file, discovery is skipped
--qr print a QR code of the tunnel URL
--open open the tunnel URL in the browser
--no-keepalive disable the periodic request that keeps the connection from idling
--no-host-rewrite disable the proxy that rewrites the Host header
--json output for programs: lifecycle events line by line (NDJSON) for run
--quiet, -q errors only, the URL is still printed
--no-color no colors (NO_COLOR is honored too)
--help, -h help
--version, -V version

Flags accept the --flag=value form. An unknown flag, or a flag without a value, is an error, not something the CLI ignores.

Provider flags

A provider’s flags carry its prefix. A flag fills a key in that provider’s section, as in the config:

Flag Key Meaning
--opentunnel-route opentunnel.route "@" (default) or a subdomain label
--opentunnel-api opentunnel.api a self-hosted opentunnel server
--cloudflared-mode cloudflared.mode quick (default) or token
--cloudflared-hostname cloudflared.hostname the public hostname of a named tunnel
--cloudflared-protocol cloudflared.protocol http2 (default) or quic
--cloudflared-binary cloudflared.binary the cloudflared executable on PATH, or a path to it

There is no flag for the Cloudflare token. The token travels only through the TUNNEL_TOKEN environment variable, because a command’s arguments are visible to every process.

Vite without the plugin

When the CLI works with a Vite server that has no @vkma.dev/tunnel plugin (your own vite or vite preview), Vite would answer “Blocked request” to the tunnel’s address. The package puts a small loopback proxy in front of your server. It rewrites the tunnel hostname into a *.localhost alias of the same length, for example m3f2vu5sb237.opentunnel.xyz into m3f2vu5sb237.open.localhost. Vite always allows *.localhost, so your config needs no change. The proxy is turned off with --no-host-rewrite.

Exit codes

Code Meaning
0 success
1 config or user error
2 network
130 aborted

Next

vkma.dev
RU
Esc