From 18628e9e367a52c09197057a92fb039560b5527d Mon Sep 17 00:00:00 2001 From: OpenCode Agent <> Date: Mon, 17 Aug 2026 15:23:40 +0000 Subject: [PATCH] fix: use native fetch with credentials for remote dashboard --- dashboard/dist/index.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/dashboard/dist/index.js b/dashboard/dist/index.js index 7099044..52eac3d 100644 --- a/dashboard/dist/index.js +++ b/dashboard/dist/index.js @@ -5,7 +5,28 @@ const { React } = SDK; const { useState, useEffect, useCallback } = SDK.hooks; const { Card, CardHeader, CardTitle, CardContent, Button } = SDK.components; - const fetchJSON = SDK.fetchJSON; + + // Use native fetch with credentials for remote dashboard + async function apiFetch(path) { + const res = await fetch(path, { credentials: "include" }); + if (!res.ok) { + const text = await res.text(); + throw new Error("API error " + res.status + ": " + text.slice(0, 100)); + } + return res.json(); + } + + async function apiPost(path) { + const res = await fetch(path, { + method: "POST", + credentials: "include" + }); + if (!res.ok) { + const text = await res.text(); + throw new Error("API error " + res.status + ": " + text.slice(0, 100)); + } + return res.json(); + } function SSHXPage() { const [link, setLink] = useState(null); @@ -16,7 +37,7 @@ setStatus("loading"); setError(null); try { - const res = await fetchJSON("/api/plugins/sshx-link/start"); + const res = await apiFetch("/api/plugins/sshx-link/start"); if (res.link) { setLink(res.link); setStatus("running"); @@ -32,7 +53,7 @@ const stopSSHX = useCallback(async function () { try { - await fetchJSON("/api/plugins/sshx-link/stop"); + await apiPost("/api/plugins/sshx-link/stop"); setLink(null); setStatus("idle"); } catch (err) { @@ -42,7 +63,7 @@ const checkStatus = useCallback(async function () { try { - const res = await fetchJSON("/api/plugins/sshx-link/status"); + const res = await apiFetch("/api/plugins/sshx-link/status"); if (res.status === "running" && res.link) { setLink(res.link); setStatus("running");