openreels-deploy
OpenReels on Hugging Face Spaces: automation REST API, no-AI-assets mode, stock-clip cap and render timeout fixes
311fa35 Download web/src/lib/apiKey.ts from abc1181/Whisper: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/abc1181/Whisper/resolve/main/web/src/lib/apiKey.ts
- Command line
-
hf download hf://spaces/abc1181/Whisper/web/src/lib/apiKey.ts
-
curl -L -o apiKey.ts https://huggingface.co/spaces/abc1181/Whisper/resolve/main/web/src/lib/apiKey.ts
1.26 kB
| const STORAGE_KEY = "openreels.apiKey.v1"; | |
| /** | |
| * Optional API key for the OpenReels server (`OPENREELS_API_KEY`). | |
| * | |
| * Stored in this browser's localStorage so the UI can call an authenticated | |
| * server. It is not a provider key and is never sent with the job payload. | |
| */ | |
| export function loadApiKey(): string { | |
| try { | |
| return (localStorage.getItem(STORAGE_KEY) ?? "").trim(); | |
| } catch { | |
| return ""; | |
| } | |
| } | |
| export function saveApiKey(value: string): void { | |
| const key = value.trim(); | |
| try { | |
| if (key) { | |
| localStorage.setItem(STORAGE_KEY, key); | |
| } else { | |
| localStorage.removeItem(STORAGE_KEY); | |
| } | |
| } catch {} | |
| } | |
| export function clearApiKey(): void { | |
| try { | |
| localStorage.removeItem(STORAGE_KEY); | |
| } catch {} | |
| } | |
| /** Headers for fetch-based API calls. */ | |
| export function apiKeyHeaders(): Record<string, string> { | |
| const key = loadApiKey(); | |
| return key ? { "X-API-Key": key } : {}; | |
| } | |
| /** | |
| * Add `?api_key=` to a URL for EventSource, media, and download links that | |
| * cannot set request headers. | |
| */ | |
| export function withApiKey(url: string): string { | |
| const key = loadApiKey(); | |
| if (!key) return url; | |
| const separator = url.includes("?") ? "&" : "?"; | |
| return `${url}${separator}api_key=${encodeURIComponent(key)}`; | |
| } | |