mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-26 21:39:43 +02:00
refactor(auth): reuse desktop token cache in API clients
This commit is contained in:
parent
652a25be37
commit
4b6bcaeb1b
2 changed files with 7 additions and 13 deletions
|
|
@ -16,7 +16,7 @@ import { z } from "zod";
|
|||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
||||
import { getDesktopAccessToken } from "@/lib/auth-fetch";
|
||||
import { authenticatedFetch } from "@/lib/auth-fetch";
|
||||
import { buildBackendUrl } from "@/lib/env-config";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
|
|
@ -157,14 +157,10 @@ function truncateCommand(command: string, maxLen = 80): string {
|
|||
// ============================================================================
|
||||
|
||||
async function downloadSandboxFile(threadId: string, filePath: string, fileName: string) {
|
||||
const token = await getDesktopAccessToken();
|
||||
const url = buildBackendUrl(`/api/v1/threads/${threadId}/sandbox/download`, {
|
||||
path: filePath,
|
||||
});
|
||||
const res = await fetch(url, {
|
||||
headers: token ? { Authorization: `Bearer ${token}` } : undefined,
|
||||
credentials: "include",
|
||||
});
|
||||
const res = await authenticatedFetch(url);
|
||||
if (!res.ok) {
|
||||
throw new Error(`Download failed: ${res.statusText}`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue