Files
011-ai-interview/start-tunnel.sh
2026-01-23 13:57:48 +08:00

33 lines
1.0 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 启动 Cloudflare Tunnel替代 ngrok无警告页面
#
# 使用方法:
# ./start-tunnel.sh
#
# 会输出一个 URL类似
# https://xxx-xxx-xxx.trycloudflare.com
#
# 把这个 URL 复制到 .env 文件的 TUNNEL_URL 配置中
echo "🚀 启动 Cloudflare Tunnel..."
echo ""
echo "等待隧道建立,会显示一个 trycloudflare.com 的 URL"
echo "请复制该 URL 到 .env 文件的 TUNNEL_URL 配置中"
echo ""
echo "按 Ctrl+C 停止隧道"
echo ""
# 检查 cloudflared 是否安装
if ! command -v cloudflared &> /dev/null; then
echo "❌ cloudflared 未安装"
echo ""
echo "请先安装 cloudflared:"
echo " macOS: brew install cloudflared"
echo " Linux: curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o cloudflared && chmod +x cloudflared && sudo mv cloudflared /usr/local/bin/"
echo " Windows: 从 https://github.com/cloudflare/cloudflared/releases 下载"
exit 1
fi
# 启动隧道
cloudflared tunnel --url http://localhost:8000