From 953d7b9e38a3e23bc0834bad14b46d92a4c5f6c0 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 1 Apr 2025 16:32:24 +0200 Subject: [PATCH 1/2] Fix API endpoint prioritization order --- src/lib/stores/sdk.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/stores/sdk.ts b/src/lib/stores/sdk.ts index fe59f6d20..8386d0007 100644 --- a/src/lib/stores/sdk.ts +++ b/src/lib/stores/sdk.ts @@ -29,8 +29,8 @@ import { Sources } from '$lib/sdk/sources'; import { building } from '$app/environment'; export function getApiEndpoint(): string { - if (building) return 'https://cloud.appwrite.io/v1'; if (VARS.APPWRITE_ENDPOINT) return VARS.APPWRITE_ENDPOINT; + if (building) return 'https://cloud.appwrite.io/v1'; return globalThis?.location?.origin + '/v1'; } From 3fa26309d56e9da4672cabc2c4e6ebe786106555 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 1 Apr 2025 16:35:38 +0200 Subject: [PATCH 2/2] Fix SDK client initialization during build --- src/lib/stores/sdk.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/stores/sdk.ts b/src/lib/stores/sdk.ts index 8386d0007..da4fc6d98 100644 --- a/src/lib/stores/sdk.ts +++ b/src/lib/stores/sdk.ts @@ -30,17 +30,18 @@ import { building } from '$app/environment'; export function getApiEndpoint(): string { if (VARS.APPWRITE_ENDPOINT) return VARS.APPWRITE_ENDPOINT; - if (building) return 'https://cloud.appwrite.io/v1'; return globalThis?.location?.origin + '/v1'; } const endpoint = getApiEndpoint(); const clientConsole = new Client(); -clientConsole.setEndpoint(endpoint).setProject('console'); - const clientProject = new Client(); -clientProject.setEndpoint(endpoint).setMode('admin'); + +if (!building) { + clientConsole.setEndpoint(endpoint).setProject('console'); + clientProject.setEndpoint(endpoint).setMode('admin'); +} const sdkForProject = { client: clientProject,