diff --git a/frontend/src/stores/auth.js b/frontend/src/stores/auth.js index 144d9ff..846493a 100644 --- a/frontend/src/stores/auth.js +++ b/frontend/src/stores/auth.js @@ -47,7 +47,7 @@ export const useAuthStore = defineStore("auth", () => { console.log("🔵 fetchUser called - fetching user from /api/auth/me"); isLoading.value = true; try { - const response = await axios.get("/auth/me", { + const response = await axios.get("/api/auth/me", { withCredentials: true, }); @@ -86,7 +86,7 @@ export const useAuthStore = defineStore("auth", () => { isLoading.value = true; try { await axios.post( - "/auth/logout", + "/api/auth/logout", {}, { withCredentials: true, @@ -111,7 +111,7 @@ export const useAuthStore = defineStore("auth", () => { const refreshToken = async () => { try { await axios.post( - "/auth/refresh", + "/api/auth/refresh", {}, { withCredentials: true, @@ -129,7 +129,7 @@ export const useAuthStore = defineStore("auth", () => { isLoading.value = true; try { const response = await axios.patch( - "/user/trade-url", + "/api/user/trade-url", { tradeUrl }, { withCredentials: true } ); @@ -155,7 +155,7 @@ export const useAuthStore = defineStore("auth", () => { isLoading.value = true; try { const response = await axios.patch( - "/user/email", + "/api/user/email", { email }, { withCredentials: true } ); @@ -178,7 +178,7 @@ export const useAuthStore = defineStore("auth", () => { const verifyEmail = async (token) => { isLoading.value = true; try { - const response = await axios.get(`/user/verify-email/${token}`, { + const response = await axios.get(`/api/user/verify-email/${token}`, { withCredentials: true, }); @@ -199,7 +199,7 @@ export const useAuthStore = defineStore("auth", () => { const getUserStats = async () => { try { - const response = await axios.get("/user/stats", { + const response = await axios.get("/api/user/stats", { withCredentials: true, }); @@ -215,7 +215,7 @@ export const useAuthStore = defineStore("auth", () => { const getBalance = async () => { try { - const response = await axios.get("/user/balance", { + const response = await axios.get("/api/user/balance", { withCredentials: true, }); diff --git a/frontend/src/utils/axios.js b/frontend/src/utils/axios.js index 2487c5b..2d3705e 100644 --- a/frontend/src/utils/axios.js +++ b/frontend/src/utils/axios.js @@ -10,7 +10,7 @@ const getApiBaseUrl = () => { return import.meta.env.VITE_API_URL; } - // In production, use the api subdomain + // In production, use the api subdomain (WITHOUT /api suffix - routes already have it) if (import.meta.env.PROD) { const currentHost = window.location.hostname; const protocol = window.location.protocol; @@ -20,13 +20,13 @@ const getApiBaseUrl = () => { currentHost === "turbotrades.dev" || currentHost === "www.turbotrades.dev" ) { - const baseUrl = `${protocol}//api.turbotrades.dev/api`; + const baseUrl = `${protocol}//api.turbotrades.dev`; console.log("🔵 Production API baseURL:", baseUrl); return baseUrl; } // For other domains, try api subdomain - const baseUrl = `${protocol}//api.${currentHost}/api`; + const baseUrl = `${protocol}//api.${currentHost}`; console.log("🔵 Production API baseURL (custom domain):", baseUrl); return baseUrl; }