Merge remote-tracking branch 'origin/master'

This commit is contained in:
2026-02-14 10:36:50 +03:00
parent 563bc0a0b6
commit 76fa2040b1

View File

@@ -3,7 +3,9 @@ import axios from 'axios'
import qs from 'qs'
import { useAuthStore } from 'stores/authStore'
export const API_BASE_URL = process.env.VITE_API_BASE_URL || '/api'
// ✅ Vite uyumlu env okuma
export const API_BASE_URL =
import.meta.env.VITE_API_BASE_URL || '/api'
const api = axios.create({
baseURL: API_BASE_URL,
@@ -13,7 +15,9 @@ const api = axios.create({
withCredentials: true
})
// REQUEST
/* ============================
REQUEST INTERCEPTOR
============================ */
api.interceptors.request.use((config) => {
const auth = useAuthStore()
const url = config.url || ''
@@ -32,7 +36,9 @@ api.interceptors.request.use((config) => {
return config
})
// RESPONSE
/* ============================
RESPONSE INTERCEPTOR
============================ */
let isLoggingOut = false
api.interceptors.response.use(
@@ -46,10 +52,15 @@ api.interceptors.response.use(
isLoggingOut = false
}
}
return Promise.reject(error)
}
)
/* ============================
HELPERS
============================ */
export const get = (u, p = {}, c = {}) =>
api.get(u, { params: p, ...c }).then(r => r.data)
@@ -63,6 +74,10 @@ export const del = (u, p = {}, c = {}) =>
api.delete(u, { params: p, ...c }).then(r => r.data)
export const download = (u, p = {}, c = {}) =>
api.get(u, { params: p, responseType: 'blob', ...c }).then(r => r.data)
api.get(u, {
params: p,
responseType: 'blob',
...c
}).then(r => r.data)
export default api