Fix OpenClaw: auto-include gateway token in dashboard link
Deploy Dashboard / deploy (push) Successful in 48s
Deploy Dashboard / deploy (push) Successful in 48s
This commit is contained in:
@@ -34,3 +34,6 @@ WEBAUTHN_ORIGIN = os.environ.get("WEBAUTHN_ORIGIN", "https://nas.jimmygan.com")
|
||||
|
||||
# CORS
|
||||
CORS_ORIGINS = os.environ.get("CORS_ORIGINS", "https://nas.jimmygan.com").split(",")
|
||||
|
||||
# OpenClaw
|
||||
OPENCLAW_GATEWAY_TOKEN = os.environ.get("OPENCLAW_GATEWAY_TOKEN", "")
|
||||
|
||||
@@ -5,7 +5,7 @@ import platform
|
||||
import time
|
||||
import httpx
|
||||
from fastapi import APIRouter, Query
|
||||
from config import TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID, VOLUME_ROOT
|
||||
from config import TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID, VOLUME_ROOT, OPENCLAW_GATEWAY_TOKEN
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -110,3 +110,8 @@ def _classify(method, path, status, user):
|
||||
return "noise"
|
||||
# Info — everything else
|
||||
return "info"
|
||||
|
||||
|
||||
@router.get("/openclaw-token")
|
||||
def openclaw_token():
|
||||
return {"token": OPENCLAW_GATEWAY_TOKEN}
|
||||
|
||||
@@ -1,7 +1,23 @@
|
||||
<script>
|
||||
import { onMount } from "svelte";
|
||||
import { get } from "../lib/api.js";
|
||||
|
||||
let isTailscale = location.hostname.startsWith("100.");
|
||||
let isLocal = location.hostname === "localhost" || location.hostname === "127.0.0.1" || location.hostname.startsWith("192.168.");
|
||||
let canAccess = isTailscale || isLocal;
|
||||
let token = $state("");
|
||||
|
||||
onMount(async () => {
|
||||
if (canAccess) {
|
||||
const res = await get("/system/openclaw-token");
|
||||
token = res?.token || "";
|
||||
}
|
||||
});
|
||||
|
||||
function clawUrl() {
|
||||
const base = `${location.protocol}//${location.hostname}:3100`;
|
||||
return token ? `${base}/#token=${token}` : base;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="space-y-4">
|
||||
@@ -22,7 +38,7 @@
|
||||
OpenClaw's security settings prevent it from being embedded inside the dashboard. Click below to launch the assistant securely in a new tab.
|
||||
</p>
|
||||
<a
|
||||
href="{location.protocol}//{location.hostname}:3100"
|
||||
href={clawUrl()}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="inline-flex items-center justify-center px-6 py-3 border border-transparent text-base font-medium rounded-lg text-white bg-primary-600 hover:bg-primary-700 shadow-sm transition-colors"
|
||||
|
||||
Reference in New Issue
Block a user