@MohamedTammam I was wondering about that because i wasn't getting any session returned
Route::group(['middleware' => ['auth:sanctum']], function () {
Route::post('/logout', [AuthController::class, 'logout']);
Route::get('/profile', [AuthController::class, 'profile']);
});
This is what i have and it should work with the front end, since it already works using Postman
Front End React JS
const useToken = JSON.parse(localStorage.getItem('token')) || '';
const headers = {
accept: 'application/json',
Authorization: 'Bearer ' + useToken.token
}
const logout = (e) => {
e.preventDefault()
apiClient
.post('/api/logout',
{
headers: headers
})
.then(() => {
console.log('000ssss')
//successful response
localStorage.removeItem('userName')
localStorage.removeItem('userEmail')
localStorage.removeItem('userLoggedIn')
navigate(`/`);
})
}