diff --git a/client/api/creators.ts b/client/api/creators.ts index b36b62ac..7b3262c4 100644 --- a/client/api/creators.ts +++ b/client/api/creators.ts @@ -51,7 +51,7 @@ export interface CreatorsResponse { }; } -const API_BASE = import.meta.env.VITE_API_BASE || ""; +const getApiBase = () => typeof window !== "undefined" ? window.location.origin : ""; export async function getCreators(filters?: { arm?: string; @@ -168,8 +168,10 @@ export async function endorseSkill( creatorId: string, skill: string, ): Promise { + const apiBase = getApiBase(); + if (!apiBase) throw new Error("No API base available"); const response = await fetch( - `${API_BASE}/api/creators/${creatorId}/endorse`, + `${apiBase}/api/creators/${creatorId}/endorse`, { method: "POST", headers: { "Content-Type": "application/json" },