YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: patch global fetch to inject auth header for all local API requests
Louis Beaumonte491e0fdfd71
diff --git a/apps/screenpipe-app-tauri/lib/api.ts b/apps/screenpipe-app-tauri/lib/api.tsindex 4584e0f16..f41eabffd 100644--- a/apps/screenpipe-app-tauri/lib/api.ts+++ b/apps/screenpipe-app-tauri/lib/api.ts@@ -72,6 +72,26 @@ function ensureInitialized(): Promise<void> {if (_authEnabled && _apiKey) {document.cookie = `screenpipe_auth=${_apiKey}; path=/; SameSite=Strict`;}++ // Patch global fetch to inject auth header for all local API requests.+ // Many components use direct fetch() instead of localFetch(), so they+ // miss the auth header entirely and get 403. This catches them all.+ if (_authEnabled && _apiKey && typeof window !== "undefined") {+ const originalFetch = window.fetch.bind(window);+ const apiKey = _apiKey;+ const apiPort = _port;+ window.fetch = (input: RequestInfo | URL, init?: RequestInit) => {+ const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;+ if (url.includes(`localhost:${apiPort}`) || url.includes(`127.0.0.1:${apiPort}`)) {+ const headers = new Headers(init?.headers);+ if (!headers.has("Authorization")) {+ headers.set("Authorization", `Bearer ${apiKey}`);+ }+ return originalFetch(input, { ...init, headers });+ }+ return originalFetch(input, init);+ };+ }} catch {// Not in Tauri context (tests, SSR) — defaults are fine}