File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
src/components/interactive Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments