← 返回
开发者工具

Dev Serve

Start and manage tmux-backed dev servers exposed through Caddy at wildcard subdomains.
启动并管理通过 Caddy 在泛域名子域名下暴露的基于 tmux 的开发服务器
brennerspear brennerspear 来源
开发者工具 clawhub v1.0.0 1 版本 99881 Key: 无需
★ 0
Stars
📥 839
下载
💾 6
安装
1
版本
#latest

概述

dev-serve — One-Command Dev Server Hosting

Start a dev server in a tmux session and expose it via Caddy at .YOUR_DOMAIN. One command up, one command down.

Setup

  1. Install the script:

```bash

cp scripts/dev-serve.sh ~/.local/bin/dev-serve

chmod +x ~/.local/bin/dev-serve

```

  1. Set your domain (one of):
    • Export DEV_SERVE_DOMAIN in your shell profile
    • Or edit the DOMAIN variable in the script
  1. Requirements:
    • Caddy running with wildcard DNS + TLS (see caddy skill)
    • tmux, jq, curl
    • Caddy admin API on localhost:2019

CLI

dev-serve up <repo-path> [port]      # Start dev server + add Caddy route
dev-serve down <name>                # Stop dev server + remove Caddy route
dev-serve ls                         # List active dev servers
dev-serve restart <name>             # Restart dev server (keep Caddy route)

How It Works

  1. Derives subdomain from the repo folder name (~/projects/myappmyapp.YOUR_DOMAIN)
  2. Detects the dev command from package.json scripts.dev (supports vite, next, nuxt, sveltekit)
  3. Auto-patches Vite allowedHosts if a vite config file exists
  4. Starts the dev server in a tmux session named dev- with --host 0.0.0.0 --port
  5. Adds a Caddy route + dashboard link to the Caddyfile
  6. Reloads Caddy via admin API (no sudo, no restart)
  7. Verifies end-to-end: waits for the dev server to listen, then polls HTTPS until 2xx/3xx (up to 90s)

Examples

# Start with auto-assigned port (starts at 5200, skips used ports)
dev-serve up ~/projects/myapp
# → https://myapp.YOUR_DOMAIN

# Explicit port
dev-serve up ~/projects/myapp 5200

# Override dev command
DEV_CMD="bun dev" dev-serve up ~/projects/myapp 5300

# Stop and clean up
dev-serve down myapp

# List what's running
dev-serve ls

Configuration

VariableDefaultDescription
--------------------------------
DEV_SERVE_DOMAIN(must be set)Your wildcard domain (e.g. mini.example.com)
DEV_SERVE_STATE_DIR~/.config/dev-serveWhere state JSON is stored
CADDYFILE~/.config/caddy/CaddyfilePath to your Caddyfile
CADDY_ADMINhttp://localhost:2019Caddy admin API address
DEV_CMD(auto-detected)Override the dev server command

Port Convention

  • Permanent services: 3100 range (managed in Caddyfile directly)
  • Dev servers: 5200+ (managed by dev-serve, auto-assigned)

Vite allowedHosts

Vite blocks requests from unrecognized hostnames. dev-serve up automatically patches vite.config.ts (or .js/.mts/.mjs) to add the subdomain. If auto-patching fails, it prints the manual fix.

Architecture

Browser (Tailscale / LAN / etc.)
  → DNS: *.YOUR_DOMAIN → your server IP
    → Caddy (HTTPS with auto certs)
      → reverse_proxy localhost:<port>
        → Dev server (in tmux session)

Companion Skills

  • caddy — Required. Sets up the Caddy reverse proxy with wildcard TLS.

Troubleshooting

Dev server not starting:

tmux attach -t dev-<name>    # see what happened

Cert not provisioning (curl exit 35):

Wait 30-60s for DNS-01 challenge. Check tail -20 /var/log/caddy-error.log.

Caddy reload failed:

caddy reload --config ~/.config/caddy/Caddyfile --address localhost:2019

403 from Vite:

The subdomain wasn't added to allowedHosts. Add it manually to your vite.config.ts:

server: { allowedHosts: ['myapp.YOUR_DOMAIN'] }

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 19:20 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

it-ops-security

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,800
knowledge-management

Research

brennerspear
对主题进行开放式研究,构建可更新的 Markdown 文档,支持交互式与深度研究模式。
★ 0 📥 4,935
it-ops-security

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 89 📥 30,709