fix(auth): avoid stale redirects after auth changes

Use full-page navigation after login/logout so the dashboard reloads
with the fresh auth cookie, and mark login/logout responses no-store.

Fixes #2100

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Emirhan
2026-06-26 11:39:49 +07:00
committed by decolua
co-authored by Cursor
parent ab5ec52f28
commit 6e9c7bf448
5 changed files with 10 additions and 19 deletions
+2 -4
View File
@@ -1,7 +1,7 @@
"use client";
import { useEffect, useMemo, useState } from "react";
import { usePathname, useRouter } from "next/navigation";
import { usePathname } from "next/navigation";
import Link from "next/link";
import PropTypes from "prop-types";
import ProviderIcon from "@/shared/components/ProviderIcon";
@@ -180,7 +180,6 @@ const getPageInfo = (pathname) => {
export default function Header({ onMenuClick, showMenuButton = true }) {
const pathname = usePathname();
const router = useRouter();
const [displayName, setDisplayName] = useState("");
const [loginMethod, setLoginMethod] = useState("");
const [donateOpen, setDonateOpen] = useState(false);
@@ -219,8 +218,7 @@ export default function Header({ onMenuClick, showMenuButton = true }) {
try {
const res = await fetch("/api/auth/logout", { method: "POST" });
if (res.ok) {
router.push("/login");
router.refresh();
window.location.assign("/login");
}
} catch (err) {
console.error("Failed to logout:", err);