# 🔧 修复 WebSocket URL 自动检测

## 问题
- 页面硬编码 `ws://192.168.31.229:7880`（局域网 IP）
- 手机通过 Tailscale 访问时，无法连接到正确的主机
- 连接超时：`could not establish signal connection: room connection has timed out (signal)`

## 解决方案
自动检测当前访问方式，动态设置 WebSocket URL：

```javascript
const hostname = window.location.hostname;
let serverUrl = 'ws://127.0.0.1:7880'; // 默认本地

if (hostname === '100.110.35.24' || hostname === 'leodemacbook-pro-2.tailbb96d5.ts.net') {
    // Tailscale 访问，使用 Tailscale IP
    serverUrl = 'ws://100.110.35.24:7880';
} else if (hostname === '192.168.31.229') {
    // 局域网访问
    serverUrl = 'ws://192.168.31.229:7880';
}
```

## 测试步骤
1. **刷新手机页面**: `https://leodemacbook-pro-2.tailbb96d5.ts.net/web-test-local.html`
2. **确认 Server URL**: 应该显示 `ws://100.110.35.24:7880`
3. **Token 已自动填充**
4. **点击"连接"按钮**

## Token
```
Room: voice-ai-meeting
Identity: phone-user
Token: eyJhbG...PktA
```

## 服务状态
- HTTP Server: 端口 8899 ✓
- LiveKit Server: 端口 7880 ✓
- Agent Worker: PID 9944 ✓
