portless README

项目的 README,来自 github.com/vercel-labs/portless。合并为一个 markdown 文件:README.md。

portless

Vercel Labs Product npm version: portless License: Apache-2.0 npm downloads per month: portless skills.sh

Portless gives local dev servers stable, named .localhost URLs. It assigns each server an available port and runs a local reverse proxy that routes requests by hostname. Your bookmarks and test scripts keep working even when the app gets a different port.

For a Next.js project named myapp, the dev script change looks like this:

- "dev": "next dev"                  # http://localhost:3000
+ "dev": "portless run next dev"     # https://myapp.localhost

Install

Portless requires Node.js 24 or later and runs on macOS, Linux, and Windows.

npm install -g portless

Quick start

From a project with a dev script in package.json, run:

portless

Portless starts the proxy if needed, then runs your dev script and prints a URL such as https://myapp.localhost.

By default, the proxy serves HTTPS on port 443. The first HTTPS run adds a local certificate authority to your system trust store and may prompt for sudo on macOS and Linux. See HTTPS setup, or pass --no-tls to use HTTP.

To choose the hostname yourself, pass a name and the dev server command. For example, from a Next.js project:

portless myapp next dev

With the default proxy settings, open https://myapp.localhost.

To use the proxy whenever you run npm run dev, prefix the command in your dev script with portless run. To pin the version for your project, use npm install -D portless and commit the lockfile.

Common workflows

Task How
Run two branches side by side Use portless run to give a linked Git worktree its own URL, such as https://fix-ui.myapp.localhost.
Start apps in a monorepo Run portless from the workspace root. Use portless.json to override app names or scripts.
Name a server that's already running With the proxy running, use portless alias api 8080 for a local HTTP server on port 8080. See Docker Compose for Compose services.
Look up app URLs Use portless list to see active routes or portless get myapp to print a URL by name.
Open a dev server on another device Use LAN mode on macOS or Linux, or share through a tunnel such as localtunnel.

Run portless doctor if a URL doesn't load. If a route hostname will not resolve, the command that registered it warns and points to portless hosts sync.

For AI agents

Install the Portless skill to teach your agent how to start dev servers and find their URLs:

npx skills add vercel-labs/portless

Add the MCP server to let a client list routes, look up URLs, and wait for an app to be ready. Clients that support MCP Tasks can receive long-running calls as tasks, and --task-grace-ms sets how long a call can run before the server returns a task. Destructive and network-changing tool calls ask for confirmation through form elicitation when the client supports it; --elicit chooses the categories. Clients on MCP 2026-07-28 can also poll or stream route and readiness change events. Use the CLI to start dev servers.

{ "mcpServers": { "portless": { "command": "portless", "args": ["mcp"] } } }

Clients that support Skills over MCP can load the bundled portless and oauth skills from the MCP server in every tool profile.

Documentation

Contributing

Use Node.js 24 or later and pnpm 11. From the repository root, run pnpm install, then pnpm --filter portless build and pnpm --filter portless test for the CLI in packages/portless. See the docs workspace for site development and AGENTS.md for change and release requirements.

Community tools

These companion tools are maintained independently by their authors, not by Vercel.

License

Apache-2.0

portless (vercel-labs/portless)

正在搜索数据库…

这是什么?Portless 是一个命令行工具,它用稳定的、带名称的 .localhost 网址替代不稳定的本地开发端口号,并默认启用 HTTPS 和 HTTP/2。
这是库还是独立的命令行工具?它是一个独立的命令行工具和本地反向代理,而不是可以在代码中导入的库。它会包装你现有的开发脚本(例如 npm run dev),并通过一个带名称的网址而不是原始端口来访问它。
我该怎么让它跑起来?全局安装,或将其作为项目的开发依赖安装,然后在项目中直接运行 portless(或 portless run)即可;它会自动通过代理运行你 package.json 中的 'dev' 脚本。
使用前我需要先装什么?只需要 Node.js(engines 要求 >=24),不需要 Python、Go、Rust 或 Ruby。在基于 Linux 的系统上,TLS 信任依赖发行版自带的证书工具(update-ca-certificates/update-ca-trust);局域网模式则需要 dns-sd(macOS)或 avahi-utils(Linux)。
安装时有哪些需要注意的坑吗?Portless 仍处于 1.0 之前的阶段:同一项目的不同贡献者可能会使用不同版本,而且磁盘上的状态目录格式可能在版本之间发生变化,这可能会迫使你重新运行 portless trust。
它在 Windows 上也能用吗,还是只支持 macOS/Linux?支持。它支持 macOS、Linux 和 Windows(包括 WSL),并针对不同平台对本地 CA 的信任做了专门处理:Windows 上使用 certutil,Linux 上使用系统信任存储,WSL 上则会同时更新两个信任存储。
代理会把我的开发服务器暴露到网络上吗?不会。默认情况下,代理只绑定到回环地址,因此只有运行它的这台机器可以访问,除非你明确启用局域网模式。
什么是局域网模式?我什么时候会用到它?加上 --lan 参数后,代理会绑定到 0.0.0.0/::,并切换为 mDNS 发现,使服务可以通过 app.local 被同一网络中的其他设备访问。但它不能与自定义顶级域名同时使用。
它如何处理 git worktree?portless run 会自动识别关联的 git worktree,并将分支名作为子域名添加在前面,因此每个 worktree 都会获得自己独一无二的 .localhost 网址,无需修改任何配置,也不会产生冲突。
为什么要用 .localhost,而不用像 .test 这样的自定义域名?.localhost 在大多数浏览器中无需任何设置即可自动解析到 127.0.0.1,但 Google 等严格的 OAuth 提供商会拒绝 .localhost 和 .test 的重定向 URI。因此 portless 也支持将你自己拥有的真实域名用作自定义顶级域名,以实现类似生产环境的基于主机名的路由。
它支持 monorepo 和 Turborepo 吗?支持。仓库根目录下的一个 portless.json 即可覆盖所有工作区包(通过 pnpm-workspace.yaml 或 npm/yarn/bun 的 workspaces 字段发现),并且无需修改 turbo.json 即可与 Turborepo 集成。
有哪些类似的项目?whistle, nginx, dev-sidecar, goproxy, gost, diffle, mitmproxy, mkcert
大小
5.9 MB
星标
12.9K
时长
9个月
提交 · 90 天