From 947fe3b66dc8036727b9fed0bc79b657f1905d1e Mon Sep 17 00:00:00 2001 From: root Date: Mon, 15 Jun 2026 11:38:03 +0200 Subject: [PATCH] fix: add /mobile prefix to all client-side fetch() calls for basePath --- src/app/forum/[threadId]/page.tsx | 2 +- src/app/forum/page.tsx | 4 ++-- src/app/halal-monitor/page.tsx | 8 ++++---- src/app/nur/page.tsx | 4 ++-- src/app/page.tsx | 2 +- src/app/profile/page.tsx | 2 +- src/app/souq/page.tsx | 4 ++-- src/app/upgrade/page.tsx | 4 ++-- src/app/wallet/page.tsx | 6 +++--- src/components/NotificationBell.tsx | 2 +- src/components/NotificationPanel.tsx | 8 ++++---- src/lib/AuthContext.tsx | 10 +++++----- src/lib/ai.ts | 2 +- 13 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/app/forum/[threadId]/page.tsx b/src/app/forum/[threadId]/page.tsx index 8d66fdc..d052148 100644 --- a/src/app/forum/[threadId]/page.tsx +++ b/src/app/forum/[threadId]/page.tsx @@ -133,7 +133,7 @@ export default function ThreadDetailPage() { setSubmitting(true); try { - const res = await fetch("/api/forum/posts", { + const res = await fetch("/mobile/api/forum/posts", { method: "POST", headers: { "Content-Type": "application/json", diff --git a/src/app/forum/page.tsx b/src/app/forum/page.tsx index eecb1c8..c6f067e 100644 --- a/src/app/forum/page.tsx +++ b/src/app/forum/page.tsx @@ -87,7 +87,7 @@ export default function ForumPage() { const fetchCategories = useCallback(async () => { try { - const res = await fetch("/api/forum/categories"); + const res = await fetch("/mobile/api/forum/categories"); const data = await res.json(); if (res.ok) { setCategories(data.categories); @@ -159,7 +159,7 @@ export default function ForumPage() { setCreating(true); try { - const res = await fetch("/api/forum/threads", { + const res = await fetch("/mobile/api/forum/threads", { method: "POST", headers: { "Content-Type": "application/json", diff --git a/src/app/halal-monitor/page.tsx b/src/app/halal-monitor/page.tsx index 1777cc5..7883574 100644 --- a/src/app/halal-monitor/page.tsx +++ b/src/app/halal-monitor/page.tsx @@ -100,7 +100,7 @@ export default function HalalMonitorPage() { const fetchUsage = useCallback(async () => { if (!token) return; try { - const res = await fetch("/api/halal/usage", { + const res = await fetch("/mobile/api/halal/usage", { headers: { Authorization: `Bearer ${token}` }, }); if (res.ok) { @@ -116,7 +116,7 @@ export default function HalalMonitorPage() { const fetchBookmarks = useCallback(async () => { if (!token) return; try { - const res = await fetch("/api/halal/bookmarks", { + const res = await fetch("/mobile/api/halal/bookmarks", { headers: { Authorization: `Bearer ${token}` }, }); if (res.ok) { @@ -133,7 +133,7 @@ export default function HalalMonitorPage() { if (!token) return; setUsageLoading(true); try { - const res = await fetch("/api/halal/usage", { + const res = await fetch("/mobile/api/halal/usage", { method: "POST", headers: { Authorization: `Bearer ${token}`, @@ -198,7 +198,7 @@ export default function HalalMonitorPage() { }); if (res.ok) fetchBookmarks(); } else { - const res = await fetch("/api/halal/bookmarks", { + const res = await fetch("/mobile/api/halal/bookmarks", { method: "POST", headers: { Authorization: `Bearer ${token}`, diff --git a/src/app/nur/page.tsx b/src/app/nur/page.tsx index 0e729d2..be90c19 100644 --- a/src/app/nur/page.tsx +++ b/src/app/nur/page.tsx @@ -77,7 +77,7 @@ function NurChat() { fetch(`/api/chat/history/${user.id}`, { headers: { Authorization: `Bearer ${token}` }, }), - fetch("/api/chat/daily", { + fetch("/mobile/api/chat/daily", { headers: { Authorization: `Bearer ${token}` }, }), ]); @@ -127,7 +127,7 @@ function NurChat() { setIsTyping(true); try { - const res = await fetch("/api/chat/send", { + const res = await fetch("/mobile/api/chat/send", { method: "POST", headers: { "Content-Type": "application/json", diff --git a/src/app/page.tsx b/src/app/page.tsx index 1a174b5..ea0211f 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -39,7 +39,7 @@ export default function HomePage() { setClaiming(true); setClaimResult(null); try { - const res = await fetch("/api/gamification/streak", { + const res = await fetch("/mobile/api/gamification/streak", { method: "POST", headers: { Authorization: `Bearer ${token}` }, }); diff --git a/src/app/profile/page.tsx b/src/app/profile/page.tsx index c9df82a..f50faac 100644 --- a/src/app/profile/page.tsx +++ b/src/app/profile/page.tsx @@ -66,7 +66,7 @@ export default function ProfilePage() { setSaveMessage(""); try { - const res = await fetch("/api/auth/profile", { + const res = await fetch("/mobile/api/auth/profile", { method: "PATCH", headers: { "Content-Type": "application/json", diff --git a/src/app/souq/page.tsx b/src/app/souq/page.tsx index 7fd4c63..96d03f7 100644 --- a/src/app/souq/page.tsx +++ b/src/app/souq/page.tsx @@ -144,7 +144,7 @@ export default function SouqPage() { return; } - const res = await fetch("/api/marketplace/listings", { + const res = await fetch("/mobile/api/marketplace/listings", { method: "POST", headers: { "Content-Type": "application/json", @@ -185,7 +185,7 @@ export default function SouqPage() { setPurchaseResult(null); try { - const res = await fetch("/api/marketplace/purchase", { + const res = await fetch("/mobile/api/marketplace/purchase", { method: "POST", headers: { "Content-Type": "application/json", diff --git a/src/app/upgrade/page.tsx b/src/app/upgrade/page.tsx index 8b1a13b..c8295e3 100644 --- a/src/app/upgrade/page.tsx +++ b/src/app/upgrade/page.tsx @@ -112,7 +112,7 @@ function UpgradeContent() { window.history.replaceState({}, "", newUrl); // Refresh user data if (token) { - fetch("/api/auth/me", { + fetch("/mobile/api/auth/me", { headers: { Authorization: `Bearer ${token}` }, }) .then((r) => r.json()) @@ -142,7 +142,7 @@ function UpgradeContent() { setMessage(null); try { - const res = await fetch("/api/upgrade/create-checkout", { + const res = await fetch("/mobile/api/upgrade/create-checkout", { method: "POST", headers: { "Content-Type": "application/json", diff --git a/src/app/wallet/page.tsx b/src/app/wallet/page.tsx index dbe6977..ea21149 100644 --- a/src/app/wallet/page.tsx +++ b/src/app/wallet/page.tsx @@ -66,7 +66,7 @@ export default function WalletPage() { const fetchWallet = async () => { try { - const res = await fetch("/api/wallet", { + const res = await fetch("/mobile/api/wallet", { headers: { Authorization: `Bearer ${token}` }, }); if (res.ok) { @@ -84,7 +84,7 @@ export default function WalletPage() { setTopupLoading(amount); try { - const res = await fetch("/api/wallet/top-up/create-checkout", { + const res = await fetch("/mobile/api/wallet/top-up/create-checkout", { method: "POST", headers: { "Content-Type": "application/json", @@ -139,7 +139,7 @@ export default function WalletPage() { setCashoutMessage(null); try { - const res = await fetch("/api/wallet", { + const res = await fetch("/mobile/api/wallet", { method: "POST", headers: { "Content-Type": "application/json", diff --git a/src/components/NotificationBell.tsx b/src/components/NotificationBell.tsx index 6ebcb09..d9599d5 100644 --- a/src/components/NotificationBell.tsx +++ b/src/components/NotificationBell.tsx @@ -14,7 +14,7 @@ export default function NotificationBell() { const fetchUnreadCount = async () => { if (!token) return; try { - const res = await fetch("/api/notifications/unread-count", { + const res = await fetch("/mobile/api/notifications/unread-count", { headers: { Authorization: `Bearer ${token}` }, }); if (res.ok) { diff --git a/src/components/NotificationPanel.tsx b/src/components/NotificationPanel.tsx index 583b2a4..383695a 100644 --- a/src/components/NotificationPanel.tsx +++ b/src/components/NotificationPanel.tsx @@ -65,7 +65,7 @@ export default function NotificationPanel({ const fetchNotifications = useCallback(async () => { if (!token) return; try { - const res = await fetch("/api/notifications", { + const res = await fetch("/mobile/api/notifications", { headers: { Authorization: `Bearer ${token}` }, }); if (res.ok) { @@ -86,7 +86,7 @@ export default function NotificationPanel({ const markAsRead = async (id: string) => { if (!token) return; try { - const res = await fetch("/api/notifications", { + const res = await fetch("/mobile/api/notifications", { method: "PATCH", headers: { "Content-Type": "application/json", @@ -108,7 +108,7 @@ export default function NotificationPanel({ const markAllAsRead = async () => { if (!token) return; try { - const res = await fetch("/api/notifications", { + const res = await fetch("/mobile/api/notifications", { method: "PATCH", headers: { "Content-Type": "application/json", @@ -130,7 +130,7 @@ export default function NotificationPanel({ const refreshCount = async () => { if (!token) return; try { - const res = await fetch("/api/notifications/unread-count", { + const res = await fetch("/mobile/api/notifications/unread-count", { headers: { Authorization: `Bearer ${token}` }, }); if (res.ok) { diff --git a/src/lib/AuthContext.tsx b/src/lib/AuthContext.tsx index 8e89277..062843a 100644 --- a/src/lib/AuthContext.tsx +++ b/src/lib/AuthContext.tsx @@ -69,7 +69,7 @@ export function AuthProvider({ children }: { children: ReactNode }) { const fetchUser = async (t: string) => { try { - const res = await fetch("/api/auth/me", { + const res = await fetch("/mobile/api/auth/me", { headers: { Authorization: `Bearer ${t}` }, }); if (res.ok) { @@ -87,7 +87,7 @@ export function AuthProvider({ children }: { children: ReactNode }) { }; const login = useCallback(async (email: string, password: string) => { - const res = await fetch("/api/auth/login", { + const res = await fetch("/mobile/api/auth/login", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email, password }), @@ -103,7 +103,7 @@ export function AuthProvider({ children }: { children: ReactNode }) { }, []); const register = useCallback(async (email: string, name: string, password: string) => { - const res = await fetch("/api/auth/register", { + const res = await fetch("/mobile/api/auth/register", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email, name, password }), @@ -134,7 +134,7 @@ export function AuthProvider({ children }: { children: ReactNode }) { const refreshStreak = useCallback(async () => { if (!token) return; try { - const res = await fetch("/api/gamification/streak", { + const res = await fetch("/mobile/api/gamification/streak", { headers: { Authorization: `Bearer ${token}` }, }); if (res.ok) { @@ -149,7 +149,7 @@ export function AuthProvider({ children }: { children: ReactNode }) { const refreshXp = useCallback(async () => { if (!token) return; try { - const res = await fetch("/api/gamification/xp", { + const res = await fetch("/mobile/api/gamification/xp", { headers: { Authorization: `Bearer ${token}` }, }); if (res.ok) { diff --git a/src/lib/ai.ts b/src/lib/ai.ts index f3c4e53..bb6fab3 100644 --- a/src/lib/ai.ts +++ b/src/lib/ai.ts @@ -3,7 +3,7 @@ export async function generateAIResponse( personaId: string, token: string ): Promise { - return fetch("/api/chat/send", { + return fetch("/mobile/api/chat/send", { method: "POST", headers: { "Content-Type": "application/json",