fix auth
This commit is contained in:
@@ -6,17 +6,10 @@
|
||||
* Get the authentication token from cookies or localStorage
|
||||
*/
|
||||
export function getAuthToken(): string | null {
|
||||
const token = document.cookie
|
||||
return document.cookie
|
||||
.split('; ')
|
||||
.find(row => row.startsWith('Authorization='))
|
||||
?.split('=')[1] || localStorage.getItem('Authorization');
|
||||
|
||||
// If token exists but doesn't have Bearer prefix, add it
|
||||
if (token && !token.startsWith('Bearer ')) {
|
||||
return `Bearer ${token}`;
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +30,7 @@ export async function logoutUser(): Promise<void> {
|
||||
await fetch(`/api/auth/logout`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': token,
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).catch(err => {
|
||||
|
||||
Reference in New Issue
Block a user