From a8d81e3482af233852fab93e9e76ec0dc881c083 Mon Sep 17 00:00:00 2001 From: ectasy663 Date: Thu, 24 Sep 2026 20:08:09 +0530 Subject: [PATCH] fix: Use fetchWithAuth for fetching test data in CBT exam view --- src/app/cbt/[examId]/page.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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();