POST
/api/auth/logout
Invalidate JWT token and log out user
URL:
https://hub.regardingwork.com/api/auth/logout
Method:
POSTAuthentication:
Required (Bearer token)Content-Type:
application/json
Request Headers
Header | Value | Required | Description |
---|---|---|---|
Authorization |
Bearer <access_token> |
Valid JWT access token |
Request Example
curl:
curl -X POST "https://hub.regardingwork.com/api/auth/logout" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
JavaScript (fetch):
const response = await fetch('https://hub.regardingwork.com/api/auth/logout', {
method: 'POST',
headers: {
'Authorization': `Bearer ${localStorage.getItem('access_token')}`
}
});
const result = await response.json();
Response
Success Response (200 OK):
{
"message": "Logged out successfully"
}
Error Responses
Status | Error | Description |
---|---|---|
401 | Authorization header required |
Missing Authorization header |
401 | Invalid or expired token |
Token is invalid or expired |
500 | Logout failed |
Internal server error |
Security & Best Practices
Important Notes
- Always call logout when user explicitly logs out
- Clear tokens from client storage after logout
- Logout invalidates the current access token
- Consider logging out on token expiration errors