diff --git a/src/app/cbt/[examId]/page.tsx b/src/app/cbt/[examId]/page.tsx index a75190e..3b0ecd3 100644 --- a/src/app/cbt/[examId]/page.tsx +++ b/src/app/cbt/[examId]/page.tsx @@ -17,6 +17,7 @@ import { Calculator } from "@/components/CBT/Calculator" import { Scratchpad } from "@/components/CBT/Scratchpad" import { PeriodicTable } from "@/components/CBT/PeriodicTable" import { ExamResult } from "@/components/CBT/ExamResult" +import { fetchWithAuth } from "@/lib/apiClient" // Dummy data for testing the CBT client engine const DUMMY_QUESTIONS = Array.from({ length: 20 }).map((_, i) => ({ @@ -98,8 +99,7 @@ export default function CBTExamPage({ params }: { params: Promise<{ examId: stri useEffect(() => { async function fetchExamData() { try { - const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'; - const testRes = await fetch(`${apiUrl}/api/tests/${examId}?user_id=${userId}`); + const testRes = await fetchWithAuth(`/api/tests/${examId}?user_id=${userId}`); if (!testRes.ok) throw new Error("Failed to fetch test structure"); const testData = await testRes.json(); @@ -125,7 +125,7 @@ export default function CBTExamPage({ params }: { params: Promise<{ examId: stri questionIds.push(...section.questions); }); - const qRes = await fetch(`${apiUrl}/api/tests/${examId}/questions`); + const qRes = await fetchWithAuth(`/api/tests/${examId}/questions`); if (!qRes.ok) throw new Error("Failed to fetch questions in bulk"); const allQuestionsData = await qRes.json();