diff --git a/frontend/app/forgot-password/page.tsx b/frontend/app/forgot-password/page.tsx index c051eaa..2bfda7f 100644 --- a/frontend/app/forgot-password/page.tsx +++ b/frontend/app/forgot-password/page.tsx @@ -3,6 +3,7 @@ import { useState } from "react"; import Link from "next/link"; import Image from "next/image"; +import { BASE_URL } from "@/lib/api/client"; import { useRouter } from "next/navigation"; import AuthCardShell, { AuthCardInner, @@ -12,11 +13,6 @@ import { Button } from "@/components/ui/button"; import { Alert, AlertDescription } from "@/components/ui/alert"; import { AlertCircle, CheckCircle2, ArrowLeft, Loader2 } from "lucide-react"; -const BASE_URL = - process.env.NEXT_PUBLIC_GATEWAY ?? - process.env.NEXT_PUBLIC_API_URL ?? - "http://localhost:8080"; - const INPUT_CLASS = "h-[50px] rounded-[13px] border border-[rgba(209,207,201,0.9)] dark:border-darkcardborder bg-[#F2F1EE] dark:bg-white/5 px-4 font-sans font-medium text-[14px] text-ink dark:text-white shadow-none focus-visible:ring-2 focus-visible:ring-saral-forest/30 focus-visible:border-saral-forest placeholder:text-ink-faint dark:placeholder:text-white/40"; @@ -50,8 +46,8 @@ export default function ForgotPasswordPage() { const data = await res.json().catch(() => ({})); setError( data?.error?.message ?? - data?.message ?? - "Too many attempts. Please try again later.", + data?.message ?? + "Too many attempts. Please try again later.", ); return; } diff --git a/frontend/app/login/page.tsx b/frontend/app/login/page.tsx index 7524c11..bfd992c 100644 --- a/frontend/app/login/page.tsx +++ b/frontend/app/login/page.tsx @@ -3,6 +3,7 @@ import { Fragment, useEffect, useState } from "react"; import Link from "next/link"; import Image from "next/image"; +import { BASE_URL } from "@/lib/api/client"; import { useRouter } from "next/navigation"; import { GoogleAuthProvider, @@ -38,11 +39,6 @@ import { EyeOff, } from "lucide-react"; -const BASE_URL = - process.env.NEXT_PUBLIC_GATEWAY ?? - process.env.NEXT_PUBLIC_API_URL ?? - "http://localhost:8080"; - // ── Provider instances (unchanged) ───────────────────────────────────────────── const googleProvider = new GoogleAuthProvider(); const githubProvider = new GithubAuthProvider(); @@ -194,7 +190,7 @@ export default function LoginPage() { if (!existingProviderId || !existingProvider) { setError( "This email is already registered with a different sign-in method. " + - "Try Google, GitHub, or Microsoft — whichever you used first.", + "Try Google, GitHub, or Microsoft — whichever you used first.", ); setLoadingId(null); return; @@ -262,8 +258,8 @@ export default function LoginPage() { } else { setEmailError( data?.error?.message ?? - data?.message ?? - "Sign-in failed. Please try again.", + data?.message ?? + "Sign-in failed. Please try again.", ); } return; diff --git a/frontend/app/reset-password/page.tsx b/frontend/app/reset-password/page.tsx index fb66498..052fecb 100644 --- a/frontend/app/reset-password/page.tsx +++ b/frontend/app/reset-password/page.tsx @@ -7,6 +7,7 @@ import { useRouter, useSearchParams } from "next/navigation"; import AuthCardShell, { AuthCardInner, } from "@/components/auth/auth-card-shell"; +import { BASE_URL } from "@/lib/api/client"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { Alert, AlertDescription } from "@/components/ui/alert"; @@ -21,11 +22,6 @@ import { XCircle, } from "lucide-react"; -const BASE_URL = - process.env.NEXT_PUBLIC_GATEWAY ?? - process.env.NEXT_PUBLIC_API_URL ?? - "http://localhost:8080"; - const INPUT_CLASS = "h-[50px] rounded-[13px] border border-[rgba(209,207,201,0.9)] dark:border-darkcardborder bg-[#F2F1EE] dark:bg-white/5 px-4 font-sans font-medium text-[14px] text-ink dark:text-white shadow-none focus-visible:ring-2 focus-visible:ring-saral-forest/30 focus-visible:border-saral-forest placeholder:text-ink-faint dark:placeholder:text-white/40"; diff --git a/frontend/app/signup/page.tsx b/frontend/app/signup/page.tsx index 599ef78..0db4c33 100644 --- a/frontend/app/signup/page.tsx +++ b/frontend/app/signup/page.tsx @@ -6,6 +6,7 @@ import { useRouter } from "next/navigation"; import { useAuthStore } from "@/lib/auth-store"; import AuthShell from "@/components/auth/auth-shell"; import { Input } from "@/components/ui/input"; +import { BASE_URL } from "@/lib/api/client"; import { Button } from "@/components/ui/button"; import { Alert, AlertDescription } from "@/components/ui/alert"; import { @@ -17,11 +18,6 @@ import { XCircle, } from "lucide-react"; -const BASE_URL = - process.env.NEXT_PUBLIC_GATEWAY ?? - process.env.NEXT_PUBLIC_API_URL ?? - "http://localhost:8080"; - const INPUT_CLASS = "h-[50px] rounded-[13px] border border-[rgba(209,207,201,0.9)] dark:border-darkcardborder bg-[#F2F1EE] dark:bg-white/5 px-4 font-sans font-medium text-[14px] text-ink dark:text-white shadow-none focus-visible:ring-2 focus-visible:ring-saral-forest/30 focus-visible:border-saral-forest placeholder:text-ink-faint dark:placeholder:text-white/40"; diff --git a/frontend/components/auth/auth-shell.tsx b/frontend/components/auth/auth-shell.tsx index 9d88ae7..39d4b08 100644 --- a/frontend/components/auth/auth-shell.tsx +++ b/frontend/components/auth/auth-shell.tsx @@ -7,6 +7,7 @@ import Image from "next/image"; import { GoogleAuthProvider, signInWithPopup } from "firebase/auth"; import { auth, isFirebaseConfigured } from "@/lib/firebase"; import { useAuthStore } from "@/lib/auth-store"; +import { BASE_URL } from "@/lib/api/client"; import { GoogleIcon, MicrosoftIcon, @@ -58,12 +59,10 @@ export default function AuthShell({ "Firebase is not configured. Add the NEXT_PUBLIC_FIREBASE_* environment variables and restart the dev server.", ); } - const result = await signInWithPopup(auth, provider); const token = await result.user.getIdToken(); - const res = await fetch( - `${process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:8080"}/auth/login`, + `${BASE_URL}/auth/login`, { method: "POST", headers: { "Content-Type": "application/json" },