fix: add /mobile prefix to all client-side fetch() calls for basePath

This commit is contained in:
root
2026-06-15 11:38:03 +02:00
parent 15300d3e42
commit 947fe3b66d
13 changed files with 29 additions and 29 deletions
+1 -1
View File
@@ -133,7 +133,7 @@ export default function ThreadDetailPage() {
setSubmitting(true); setSubmitting(true);
try { try {
const res = await fetch("/api/forum/posts", { const res = await fetch("/mobile/api/forum/posts", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
+2 -2
View File
@@ -87,7 +87,7 @@ export default function ForumPage() {
const fetchCategories = useCallback(async () => { const fetchCategories = useCallback(async () => {
try { try {
const res = await fetch("/api/forum/categories"); const res = await fetch("/mobile/api/forum/categories");
const data = await res.json(); const data = await res.json();
if (res.ok) { if (res.ok) {
setCategories(data.categories); setCategories(data.categories);
@@ -159,7 +159,7 @@ export default function ForumPage() {
setCreating(true); setCreating(true);
try { try {
const res = await fetch("/api/forum/threads", { const res = await fetch("/mobile/api/forum/threads", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
+4 -4
View File
@@ -100,7 +100,7 @@ export default function HalalMonitorPage() {
const fetchUsage = useCallback(async () => { const fetchUsage = useCallback(async () => {
if (!token) return; if (!token) return;
try { try {
const res = await fetch("/api/halal/usage", { const res = await fetch("/mobile/api/halal/usage", {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}); });
if (res.ok) { if (res.ok) {
@@ -116,7 +116,7 @@ export default function HalalMonitorPage() {
const fetchBookmarks = useCallback(async () => { const fetchBookmarks = useCallback(async () => {
if (!token) return; if (!token) return;
try { try {
const res = await fetch("/api/halal/bookmarks", { const res = await fetch("/mobile/api/halal/bookmarks", {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}); });
if (res.ok) { if (res.ok) {
@@ -133,7 +133,7 @@ export default function HalalMonitorPage() {
if (!token) return; if (!token) return;
setUsageLoading(true); setUsageLoading(true);
try { try {
const res = await fetch("/api/halal/usage", { const res = await fetch("/mobile/api/halal/usage", {
method: "POST", method: "POST",
headers: { headers: {
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
@@ -198,7 +198,7 @@ export default function HalalMonitorPage() {
}); });
if (res.ok) fetchBookmarks(); if (res.ok) fetchBookmarks();
} else { } else {
const res = await fetch("/api/halal/bookmarks", { const res = await fetch("/mobile/api/halal/bookmarks", {
method: "POST", method: "POST",
headers: { headers: {
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
+2 -2
View File
@@ -77,7 +77,7 @@ function NurChat() {
fetch(`/api/chat/history/${user.id}`, { fetch(`/api/chat/history/${user.id}`, {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}), }),
fetch("/api/chat/daily", { fetch("/mobile/api/chat/daily", {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}), }),
]); ]);
@@ -127,7 +127,7 @@ function NurChat() {
setIsTyping(true); setIsTyping(true);
try { try {
const res = await fetch("/api/chat/send", { const res = await fetch("/mobile/api/chat/send", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
+1 -1
View File
@@ -39,7 +39,7 @@ export default function HomePage() {
setClaiming(true); setClaiming(true);
setClaimResult(null); setClaimResult(null);
try { try {
const res = await fetch("/api/gamification/streak", { const res = await fetch("/mobile/api/gamification/streak", {
method: "POST", method: "POST",
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}); });
+1 -1
View File
@@ -66,7 +66,7 @@ export default function ProfilePage() {
setSaveMessage(""); setSaveMessage("");
try { try {
const res = await fetch("/api/auth/profile", { const res = await fetch("/mobile/api/auth/profile", {
method: "PATCH", method: "PATCH",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
+2 -2
View File
@@ -144,7 +144,7 @@ export default function SouqPage() {
return; return;
} }
const res = await fetch("/api/marketplace/listings", { const res = await fetch("/mobile/api/marketplace/listings", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@@ -185,7 +185,7 @@ export default function SouqPage() {
setPurchaseResult(null); setPurchaseResult(null);
try { try {
const res = await fetch("/api/marketplace/purchase", { const res = await fetch("/mobile/api/marketplace/purchase", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
+2 -2
View File
@@ -112,7 +112,7 @@ function UpgradeContent() {
window.history.replaceState({}, "", newUrl); window.history.replaceState({}, "", newUrl);
// Refresh user data // Refresh user data
if (token) { if (token) {
fetch("/api/auth/me", { fetch("/mobile/api/auth/me", {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}) })
.then((r) => r.json()) .then((r) => r.json())
@@ -142,7 +142,7 @@ function UpgradeContent() {
setMessage(null); setMessage(null);
try { try {
const res = await fetch("/api/upgrade/create-checkout", { const res = await fetch("/mobile/api/upgrade/create-checkout", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
+3 -3
View File
@@ -66,7 +66,7 @@ export default function WalletPage() {
const fetchWallet = async () => { const fetchWallet = async () => {
try { try {
const res = await fetch("/api/wallet", { const res = await fetch("/mobile/api/wallet", {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}); });
if (res.ok) { if (res.ok) {
@@ -84,7 +84,7 @@ export default function WalletPage() {
setTopupLoading(amount); setTopupLoading(amount);
try { try {
const res = await fetch("/api/wallet/top-up/create-checkout", { const res = await fetch("/mobile/api/wallet/top-up/create-checkout", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@@ -139,7 +139,7 @@ export default function WalletPage() {
setCashoutMessage(null); setCashoutMessage(null);
try { try {
const res = await fetch("/api/wallet", { const res = await fetch("/mobile/api/wallet", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
+1 -1
View File
@@ -14,7 +14,7 @@ export default function NotificationBell() {
const fetchUnreadCount = async () => { const fetchUnreadCount = async () => {
if (!token) return; if (!token) return;
try { try {
const res = await fetch("/api/notifications/unread-count", { const res = await fetch("/mobile/api/notifications/unread-count", {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}); });
if (res.ok) { if (res.ok) {
+4 -4
View File
@@ -65,7 +65,7 @@ export default function NotificationPanel({
const fetchNotifications = useCallback(async () => { const fetchNotifications = useCallback(async () => {
if (!token) return; if (!token) return;
try { try {
const res = await fetch("/api/notifications", { const res = await fetch("/mobile/api/notifications", {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}); });
if (res.ok) { if (res.ok) {
@@ -86,7 +86,7 @@ export default function NotificationPanel({
const markAsRead = async (id: string) => { const markAsRead = async (id: string) => {
if (!token) return; if (!token) return;
try { try {
const res = await fetch("/api/notifications", { const res = await fetch("/mobile/api/notifications", {
method: "PATCH", method: "PATCH",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@@ -108,7 +108,7 @@ export default function NotificationPanel({
const markAllAsRead = async () => { const markAllAsRead = async () => {
if (!token) return; if (!token) return;
try { try {
const res = await fetch("/api/notifications", { const res = await fetch("/mobile/api/notifications", {
method: "PATCH", method: "PATCH",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@@ -130,7 +130,7 @@ export default function NotificationPanel({
const refreshCount = async () => { const refreshCount = async () => {
if (!token) return; if (!token) return;
try { try {
const res = await fetch("/api/notifications/unread-count", { const res = await fetch("/mobile/api/notifications/unread-count", {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}); });
if (res.ok) { if (res.ok) {
+5 -5
View File
@@ -69,7 +69,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const fetchUser = async (t: string) => { const fetchUser = async (t: string) => {
try { try {
const res = await fetch("/api/auth/me", { const res = await fetch("/mobile/api/auth/me", {
headers: { Authorization: `Bearer ${t}` }, headers: { Authorization: `Bearer ${t}` },
}); });
if (res.ok) { if (res.ok) {
@@ -87,7 +87,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
}; };
const login = useCallback(async (email: string, password: string) => { 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", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, password }), 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 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", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, name, password }), body: JSON.stringify({ email, name, password }),
@@ -134,7 +134,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const refreshStreak = useCallback(async () => { const refreshStreak = useCallback(async () => {
if (!token) return; if (!token) return;
try { try {
const res = await fetch("/api/gamification/streak", { const res = await fetch("/mobile/api/gamification/streak", {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}); });
if (res.ok) { if (res.ok) {
@@ -149,7 +149,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const refreshXp = useCallback(async () => { const refreshXp = useCallback(async () => {
if (!token) return; if (!token) return;
try { try {
const res = await fetch("/api/gamification/xp", { const res = await fetch("/mobile/api/gamification/xp", {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
}); });
if (res.ok) { if (res.ok) {
+1 -1
View File
@@ -3,7 +3,7 @@ export async function generateAIResponse(
personaId: string, personaId: string,
token: string token: string
): Promise<Response> { ): Promise<Response> {
return fetch("/api/chat/send", { return fetch("/mobile/api/chat/send", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",