From 8bda63db7ec6d65f56130984fb9606648e0f0b63 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sun, 16 Nov 2025 08:48:59 +0000 Subject: [PATCH] completionId: cgen-7ce25714075c473cb10950d6a93de61c cgen-7ce25714075c473cb10950d6a93de61c --- client/pages/dashboards/FoundationDashboard.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/client/pages/dashboards/FoundationDashboard.tsx b/client/pages/dashboards/FoundationDashboard.tsx index fe984d62..e04d9f4c 100644 --- a/client/pages/dashboards/FoundationDashboard.tsx +++ b/client/pages/dashboards/FoundationDashboard.tsx @@ -33,7 +33,7 @@ import { CoursesWidget } from "@/components/CoursesWidget"; import { MentorshipWidget } from "@/components/MentorshipWidget"; import { AchievementsWidget } from "@/components/AchievementsWidget"; -const API_BASE = import.meta.env.VITE_API_BASE || ""; +const getApiBase = () => typeof window !== "undefined" ? window.location.origin : ""; export default function FoundationDashboard() { const navigate = useNavigate(); @@ -61,7 +61,7 @@ export default function FoundationDashboard() { if (!token) throw new Error("No auth token"); try { - const coursesRes = await fetch(`${API_BASE}/api/foundation/courses`, { + const coursesRes = await fetch(`${apiBase}/api/foundation/courses`, { headers: { Authorization: `Bearer ${token}` }, }); if ( @@ -76,8 +76,13 @@ export default function FoundationDashboard() { } try { + const apiBase = getApiBase(); + if (!apiBase) { + console.warn("[Foundation] No API base available"); + return; + } const mentorRes = await fetch( - `${API_BASE}/api/foundation/mentorships`, + `${apiBase}/api/foundation/mentorships`, { headers: { Authorization: `Bearer ${token}` }, },