mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
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:
committed by
decolua
co-authored by
Cursor
parent
ab5ec52f28
commit
6e9c7bf448
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user