From f9bfa5febbbce672c532cf0ae82b3378c9b26d45 Mon Sep 17 00:00:00 2001 From: ilia Date: Sun, 4 Jan 2026 13:14:16 -0500 Subject: [PATCH] refactor: Update login redirection method for session handling - Replaced router.push with window.location.href to ensure a full page reload after login, allowing the session cookie to be read correctly before authentication checks. - Updated comments to clarify the reason for this change in the login flow. --- app/login/page.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/login/page.tsx b/app/login/page.tsx index 92147e6..b8711df 100644 --- a/app/login/page.tsx +++ b/app/login/page.tsx @@ -2,10 +2,8 @@ import { useState } from "react" import { signIn } from "next-auth/react" -import { useRouter } from "next/navigation" export default function LoginPage() { - const router = useRouter() const [email, setEmail] = useState("") const [password, setPassword] = useState("") const [error, setError] = useState("") @@ -32,8 +30,9 @@ export default function LoginPage() { const params = new URLSearchParams(window.location.search) const callbackUrl = params.get("callbackUrl") || "/photos" console.log("Redirecting to:", callbackUrl) - router.push(callbackUrl) - router.refresh() + // Use window.location.href to force a full page reload + // This ensures the session cookie is read before middleware checks authentication + window.location.href = callbackUrl } else { setError("Login failed. Please try again.") }