Spaces:
Sleeping
Sleeping
refactor: remove control route and automated gateway token injection for manual authentication
Browse files- README.md +5 -6
- health-server.js +2 -20
README.md
CHANGED
|
@@ -49,7 +49,7 @@ license: mit
|
|
| 49 |
- 👥 **Multi-User Messaging:** Support for Telegram (multi-user) and WhatsApp (pairing).
|
| 50 |
- 📊 **Visual Dashboard:** Beautiful Web UI to monitor uptime, sync status, and active models.
|
| 51 |
- 🔔 **Webhooks:** Get notified on restarts or backup failures via standard webhooks.
|
| 52 |
-
- 🔐 **Flexible Auth:** Secure the Control UI with either a gateway token or password
|
| 53 |
- 🏠 **100% HF-Native:** Runs entirely on HuggingFace’s free infrastructure (2 vCPU, 16GB RAM).
|
| 54 |
|
| 55 |
## 🎥 Video Tutorial
|
|
@@ -99,10 +99,9 @@ After restarting, the bot should appear online on Telegram.
|
|
| 99 |
To use WhatsApp:
|
| 100 |
|
| 101 |
1. Visit your Space URL. It opens the dashboard at `/dashboard` by default, then click **Open Control UI**.
|
| 102 |
-
2.
|
| 103 |
-
3.
|
| 104 |
-
|
| 105 |
-
The Control UI now redirects to `/?token=...` automatically, so you usually won't need to paste `GATEWAY_TOKEN` manually in the browser.
|
| 106 |
|
| 107 |
## 💾 Workspace Backup *(Optional)*
|
| 108 |
|
|
@@ -291,7 +290,7 @@ HuggingClaw keeps the Space awake without external cron tools:
|
|
| 291 |
- **Backup restore failing:** Make sure `HF_USERNAME` and `HF_TOKEN` are correct (token needs write access to your Dataset).
|
| 292 |
- **Space keeps sleeping:** Check logs for `Keep-alive` messages. Ensure `KEEP_ALIVE_INTERVAL` isn’t set to `0`.
|
| 293 |
- **Auth errors / proxy:** If you see reverse-proxy auth errors, add the logged IPs under `TRUSTED_PROXIES` (from logs `remote=x.x.x.x`).
|
| 294 |
-
- **Control UI says too many failed authentication attempts:** Wait for the retry window to expire, then open the Space in an incognito window or clear site storage for your Space
|
| 295 |
- **WhatsApp lost its session after restart:** Make sure `HF_USERNAME` and `HF_TOKEN` are configured so the hidden session backup can be restored on boot.
|
| 296 |
- **UI blocked (CORS):** Set `ALLOWED_ORIGINS=https://your-space-name.hf.space`.
|
| 297 |
- **Version mismatches:** Pin a specific OpenClaw build with the `OPENCLAW_VERSION` Variable in HF Spaces, or `--build-arg OPENCLAW_VERSION=...` locally.
|
|
|
|
| 49 |
- 👥 **Multi-User Messaging:** Support for Telegram (multi-user) and WhatsApp (pairing).
|
| 50 |
- 📊 **Visual Dashboard:** Beautiful Web UI to monitor uptime, sync status, and active models.
|
| 51 |
- 🔔 **Webhooks:** Get notified on restarts or backup failures via standard webhooks.
|
| 52 |
+
- 🔐 **Flexible Auth:** Secure the Control UI with either a gateway token or password.
|
| 53 |
- 🏠 **100% HF-Native:** Runs entirely on HuggingFace’s free infrastructure (2 vCPU, 16GB RAM).
|
| 54 |
|
| 55 |
## 🎥 Video Tutorial
|
|
|
|
| 99 |
To use WhatsApp:
|
| 100 |
|
| 101 |
1. Visit your Space URL. It opens the dashboard at `/dashboard` by default, then click **Open Control UI**.
|
| 102 |
+
2. Enter your `GATEWAY_TOKEN` when the Control UI prompts you to log in.
|
| 103 |
+
3. In the Control UI, go to **Channels** → **WhatsApp** → **Login**.
|
| 104 |
+
4. Scan the QR code with your phone. 📱
|
|
|
|
| 105 |
|
| 106 |
## 💾 Workspace Backup *(Optional)*
|
| 107 |
|
|
|
|
| 290 |
- **Backup restore failing:** Make sure `HF_USERNAME` and `HF_TOKEN` are correct (token needs write access to your Dataset).
|
| 291 |
- **Space keeps sleeping:** Check logs for `Keep-alive` messages. Ensure `KEEP_ALIVE_INTERVAL` isn’t set to `0`.
|
| 292 |
- **Auth errors / proxy:** If you see reverse-proxy auth errors, add the logged IPs under `TRUSTED_PROXIES` (from logs `remote=x.x.x.x`).
|
| 293 |
+
- **Control UI says too many failed authentication attempts:** Wait for the retry window to expire, then open the Space in an incognito window or clear site storage for your Space before logging in again with `GATEWAY_TOKEN`.
|
| 294 |
- **WhatsApp lost its session after restart:** Make sure `HF_USERNAME` and `HF_TOKEN` are configured so the hidden session backup can be restored on boot.
|
| 295 |
- **UI blocked (CORS):** Set `ALLOWED_ORIGINS=https://your-space-name.hf.space`.
|
| 296 |
- **Version mismatches:** Pin a specific OpenClaw build with the `OPENCLAW_VERSION` Variable in HF Spaces, or `--build-arg OPENCLAW_VERSION=...` locally.
|
health-server.js
CHANGED
|
@@ -33,17 +33,8 @@ function isDashboardRoute(pathname) {
|
|
| 33 |
return pathname === "/dashboard" || pathname === "/dashboard/";
|
| 34 |
}
|
| 35 |
|
| 36 |
-
function isControlRoute(pathname) {
|
| 37 |
-
return pathname === "/control" || pathname === "/control/";
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
function isLocalRoute(pathname) {
|
| 41 |
-
return (
|
| 42 |
-
pathname === "/health" ||
|
| 43 |
-
pathname === "/status" ||
|
| 44 |
-
isDashboardRoute(pathname) ||
|
| 45 |
-
isControlRoute(pathname)
|
| 46 |
-
);
|
| 47 |
}
|
| 48 |
|
| 49 |
function appendForwarded(existingValue, nextValue) {
|
|
@@ -387,7 +378,7 @@ function renderDashboard() {
|
|
| 387 |
<span class="stat-label">Telegram</span>
|
| 388 |
<span id="tg-status">Loading...</span>
|
| 389 |
</div>
|
| 390 |
-
<a href="/
|
| 391 |
</div>
|
| 392 |
|
| 393 |
<div class="stat-card" style="width: 100%;">
|
|
@@ -591,15 +582,6 @@ const server = http.createServer((req, res) => {
|
|
| 591 |
return;
|
| 592 |
}
|
| 593 |
|
| 594 |
-
if ((pathname === "/" || isControlRoute(pathname)) && req.method === "GET" && !parsedUrl.searchParams.get("token") && GATEWAY_TOKEN) {
|
| 595 |
-
res.writeHead(302, {
|
| 596 |
-
Location: `/?token=${encodeURIComponent(GATEWAY_TOKEN)}`,
|
| 597 |
-
"Cache-Control": "no-store",
|
| 598 |
-
});
|
| 599 |
-
res.end();
|
| 600 |
-
return;
|
| 601 |
-
}
|
| 602 |
-
|
| 603 |
proxyHttp(req, res);
|
| 604 |
});
|
| 605 |
|
|
|
|
| 33 |
return pathname === "/dashboard" || pathname === "/dashboard/";
|
| 34 |
}
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
function isLocalRoute(pathname) {
|
| 37 |
+
return pathname === "/health" || pathname === "/status" || isDashboardRoute(pathname);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
}
|
| 39 |
|
| 40 |
function appendForwarded(existingValue, nextValue) {
|
|
|
|
| 378 |
<span class="stat-label">Telegram</span>
|
| 379 |
<span id="tg-status">Loading...</span>
|
| 380 |
</div>
|
| 381 |
+
<a href="/" class="stat-btn">Open Control UI</a>
|
| 382 |
</div>
|
| 383 |
|
| 384 |
<div class="stat-card" style="width: 100%;">
|
|
|
|
| 582 |
return;
|
| 583 |
}
|
| 584 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 585 |
proxyHttp(req, res);
|
| 586 |
});
|
| 587 |
|