Spaces:
Paused
Paused
Download console/src/plugins/hostSdk/fetch.ts from mysticaldragon/HF: direct link, hf CLI and curl.
- Browser
- Download file 664 Bytes
-
https://huggingface.co/spaces/mysticaldragon/HF/resolve/main/console/src/plugins/hostSdk/fetch.ts
- Command line
-
hf download hf://spaces/mysticaldragon/HF/console/src/plugins/hostSdk/fetch.ts
-
curl -L -o fetch.ts https://huggingface.co/spaces/mysticaldragon/HF/resolve/main/console/src/plugins/hostSdk/fetch.ts
664 Bytes
| /** | |
| * hostSdk/fetch.ts — auth-aware fetch wrapper for plugins. | |
| * | |
| * Reuses `buildAuthHeaders()` which already injects `Authorization` | |
| * and `X-Agent-Id` from the agent store. Plugin callers pass an API path | |
| * (e.g. "/console/chat") and get back a normal Response. | |
| */ | |
| import { getApiUrl } from "../../api/config"; | |
| import { buildAuthHeaders } from "../../api/authHeaders"; | |
| export async function hostFetch( | |
| path: string, | |
| init?: RequestInit, | |
| ): Promise<Response> { | |
| const headers: Record<string, string> = { | |
| ...buildAuthHeaders(), | |
| ...((init?.headers as Record<string, string>) ?? {}), | |
| }; | |
| return fetch(getApiUrl(path), { ...init, headers }); | |
| } | |