Reduce scan terminal origin load

This commit is contained in:
2569718930@qq.com
2026-05-30 21:55:45 +08:00
parent 9c239c0394
commit 74a2d71644
3 changed files with 42 additions and 3 deletions
@@ -3,6 +3,7 @@
import {
buildBrowserBackendHeaders,
fetchBackendApi,
hasDirectBackendApiBaseUrl,
} from "@/lib/backend-api";
import { DASHBOARD_REFRESH_POLICY_MS } from "@/lib/refresh-policy";
import type {
@@ -144,11 +145,14 @@ async function getTerminal({
if (forceRefresh) {
params.set("_ts", String(Date.now()));
}
const headers = await buildBrowserBackendHeaders({ Accept: "application/json" });
const directBackend = hasDirectBackendApiBaseUrl();
const headers = directBackend
? await buildBrowserBackendHeaders({ Accept: "application/json" })
: new Headers({ Accept: "application/json" });
return readJsonOrThrow<ScanTerminalResponse>(
`/api/scan/terminal?${params.toString()}`,
{
cache: "no-store",
cache: forceRefresh || directBackend ? "no-store" : "default",
headers,
signal,
},