This commit is contained in:
ghassan committed 2026-08-04 11:26:25 +03:00
1 parent d0834df8df
commit 6dc35134fa
171 files changed
+19241 -49

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
import axios from 'axios'
export const apiClient = axios.create({
baseURL: '/api/v1',
withCredentials: true,
withXSRFToken: true,
headers: { Accept: 'application/json' },
})
export async function ensureCsrfCookie() {
await axios.get('/sanctum/csrf-cookie', { baseURL: '/', withCredentials: true, withXSRFToken: true })
}
export const UNAUTHORIZED_EVENT = 'auth:unauthorized'
apiClient.interceptors.response.use(
(response) => response,
(error) => {
if (error.response?.status === 401) {
window.dispatchEvent(new CustomEvent(UNAUTHORIZED_EVENT))
}
return Promise.reject(error)
},
)