Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(desktop): route API requests through configured server URL

Richie McIlroy816ea381fe57
diff --git a/apps/desktop/src/utils/web-api.ts b/apps/desktop/src/utils/web-api.ts
index 2e57f2865..769001a62 100644
--- a/apps/desktop/src/utils/web-api.ts
+++ b/apps/desktop/src/utils/web-api.ts
@@ -6,14 +6,27 @@ import {
import { fetch } from "@tauri-apps/plugin-http";
import { type ApiFetcher, initClient } from "@ts-rest/core";
-import { authStore } from "~/store";
+import { authStore, generalSettingsStore } from "~/store";
import { clientEnv } from "./env";
+import { resolveServerRequestPath } from "./server-url-routing";
+
+export async function getConfiguredServerUrl() {
+ return (
+ (await generalSettingsStore.get())?.serverUrl ?? clientEnv.VITE_SERVER_URL
+ );
+}
+
+async function resolveRequestPath(path: string) {
+ const serverUrl = await getConfiguredServerUrl();
+ return resolveServerRequestPath(path, serverUrl, clientEnv.VITE_SERVER_URL);
+}
const api: ApiFetcher = async (args) => {
const bypassSecret = import.meta.env.VITE_VERCEL_AUTOMATION_BYPASS_SECRET;
if (bypassSecret) args.headers["x-vercel-protection-bypass"] = bypassSecret;
- const resp = await fetch(args.path, args);
+ const path = await resolveRequestPath(args.path);
+ const resp = await fetch(path, args);
let body: unknown;