Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -3,9 +3,8 @@ import axios from 'axios'
|
|||||||
import qs from 'qs'
|
import qs from 'qs'
|
||||||
import { useAuthStore } from 'stores/authStore'
|
import { useAuthStore } from 'stores/authStore'
|
||||||
|
|
||||||
// ✅ Vite uyumlu env okuma
|
// 🔥 ENV YOK
|
||||||
export const API_BASE_URL =
|
export const API_BASE_URL = '/api'
|
||||||
import.meta.env.VITE_API_BASE_URL || '/api'
|
|
||||||
|
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
baseURL: API_BASE_URL,
|
baseURL: API_BASE_URL,
|
||||||
@@ -15,9 +14,6 @@ const api = axios.create({
|
|||||||
withCredentials: true
|
withCredentials: true
|
||||||
})
|
})
|
||||||
|
|
||||||
/* ============================
|
|
||||||
REQUEST INTERCEPTOR
|
|
||||||
============================ */
|
|
||||||
api.interceptors.request.use((config) => {
|
api.interceptors.request.use((config) => {
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
const url = config.url || ''
|
const url = config.url || ''
|
||||||
@@ -36,9 +32,6 @@ api.interceptors.request.use((config) => {
|
|||||||
return config
|
return config
|
||||||
})
|
})
|
||||||
|
|
||||||
/* ============================
|
|
||||||
RESPONSE INTERCEPTOR
|
|
||||||
============================ */
|
|
||||||
let isLoggingOut = false
|
let isLoggingOut = false
|
||||||
|
|
||||||
api.interceptors.response.use(
|
api.interceptors.response.use(
|
||||||
@@ -52,15 +45,10 @@ api.interceptors.response.use(
|
|||||||
isLoggingOut = false
|
isLoggingOut = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
/* ============================
|
|
||||||
HELPERS
|
|
||||||
============================ */
|
|
||||||
|
|
||||||
export const get = (u, p = {}, c = {}) =>
|
export const get = (u, p = {}, c = {}) =>
|
||||||
api.get(u, { params: p, ...c }).then(r => r.data)
|
api.get(u, { params: p, ...c }).then(r => r.data)
|
||||||
|
|
||||||
@@ -74,10 +62,7 @@ export const del = (u, p = {}, c = {}) =>
|
|||||||
api.delete(u, { params: p, ...c }).then(r => r.data)
|
api.delete(u, { params: p, ...c }).then(r => r.data)
|
||||||
|
|
||||||
export const download = (u, p = {}, c = {}) =>
|
export const download = (u, p = {}, c = {}) =>
|
||||||
api.get(u, {
|
api.get(u, { params: p, responseType: 'blob', ...c })
|
||||||
params: p,
|
.then(r => r.data)
|
||||||
responseType: 'blob',
|
|
||||||
...c
|
|
||||||
}).then(r => r.data)
|
|
||||||
|
|
||||||
export default api
|
export default api
|
||||||
|
|||||||
Reference in New Issue
Block a user