Skip to content

Commit 1733572

Browse files
committed
update with session, check if it works on prod
1 parent 669be72 commit 1733572

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/components/interactive/UserMenu.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,26 @@ export default function UserMenu({ directusUrl, provider = "authentik" }: Props)
7878
// Logged in → POST /auth/logout, then redirect back
7979
const onLogout = async () => {
8080
try {
81-
await fetch(`${directusUrl}/auth/logout`, {
81+
const res = await fetch(`${directusUrl}/auth/logout`, {
8282
method: "POST",
83-
credentials: "include",
84-
headers: { Accept: "application/json", "Content-Type": "application/json" },
85-
body: "{}", // avoids 400 on some builds
83+
credentials: "include", // <-- REQUIRED for cookies
84+
headers: { "Content-Type": "application/json" },
85+
body: JSON.stringify({ mode: "session" })
8686
});
87+
88+
// Directus often returns 204 No Content on success
89+
if (!res.ok) {
90+
const txt = await res.text().catch(() => "");
91+
console.error("Logout failed:", res.status, txt);
92+
return;
93+
}
94+
95+
// clear any app-side state and bounce
96+
// window.location.replace(currentUrl);
8797
} catch (e) {
8898
console.error("Logout error:", e);
89-
} finally {
90-
// window.location.replace(currentUrl);
9199
}
100+
92101
};
93102

94103
return (

0 commit comments

Comments
 (0)