refactor(web): extract isTauri into a leaf platform module

This commit is contained in:
Offending Commit
2026-06-02 11:36:21 -05:00
parent 3bb1150773
commit d4452abcea
4 changed files with 27 additions and 11 deletions

View File

@@ -1,12 +1,8 @@
import { fetch as tauriFetch } from "@tauri-apps/plugin-http";
import { isTauri } from "@/lib/platform";
// Route fetch through Rust (reqwest) when running in Tauri — bypasses WebView CORS enforcement.
// Falls back to native browser fetch during plain web dev (`pnpm dev:web`).
const isTauri = Boolean(
typeof window !== "undefined" &&
(window as unknown as Record<string, unknown>).__TAURI_INTERNALS__,
);
export const httpFetch: typeof globalThis.fetch = isTauri
// Falls back to native browser fetch during plain web dev.
export const httpFetch: typeof globalThis.fetch = isTauri()
? (tauriFetch as typeof globalThis.fetch)
: globalThis.fetch;