- Added hooks for listing, creating, updating, deleting, sharing, and merging people. - Introduced a new route for person details and media. - Implemented clustering faces functionality. - Created services for person-related API interactions. feat: Introduce tag management functionality - Added hooks for listing, adding, and removing tags from media. - Created services for tag-related API interactions. feat: Enhance user authentication handling - Added a hook to fetch current user details. - Updated auth storage to manage user state more effectively. feat: Update album management features - Enhanced album service to return created album details. - Updated API handlers to return album responses upon creation. - Modified album repository to return created album. feat: Implement media management improvements - Added media details fetching and processing of media URLs. - Enhanced media upload functionality to return processed media. feat: Introduce face management features - Added services for listing faces for media and assigning faces to persons. fix: Update API client to clear authentication state on 401 errors.
33 lines
745 B
TypeScript
33 lines
745 B
TypeScript
import axios from 'axios'
|
|
import { useAuthStorage } from '@/hooks/use-auth-storage'
|
|
|
|
|
|
const apiClient = axios.create({
|
|
baseURL: import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000/api/v1',
|
|
})
|
|
|
|
apiClient.interceptors.request.use(
|
|
(config) => {
|
|
const token = useAuthStorage.getState().token
|
|
if (token) {
|
|
config.headers.Authorization = `Bearer ${token}`
|
|
}
|
|
return config
|
|
},
|
|
(error) => {
|
|
return Promise.reject(error)
|
|
},
|
|
)
|
|
|
|
apiClient.interceptors.response.use(
|
|
(response) => response,
|
|
(error) => {
|
|
if (error.response && error.response.status === 401) {
|
|
useAuthStorage.getState().clearAuth()
|
|
window.location.reload()
|
|
}
|
|
return Promise.reject(error)
|
|
},
|
|
)
|
|
|
|
export default apiClient |