Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-04-16 15:18:44 +03:00
parent 1831c45a0c
commit 2d369e7d7d
40 changed files with 3477 additions and 97 deletions
+9
View File
@@ -1,12 +1,14 @@
import axios from 'axios'
import qs from 'qs'
import { useAuthStore } from 'stores/authStore'
import { DEFAULT_LOCALE, normalizeLocale } from 'src/i18n/languages'
const rawBaseUrl =
(typeof process !== 'undefined' && process.env?.VITE_API_BASE_URL) || '/api'
export const API_BASE_URL = String(rawBaseUrl).trim().replace(/\/+$/, '')
const AUTH_REFRESH_PATH = '/auth/refresh'
const LOCALE_STORAGE_KEY = 'bss.locale'
const api = axios.create({
baseURL: API_BASE_URL,
@@ -74,6 +76,11 @@ function redirectToLogin() {
window.location.hash = '/login'
}
function getRequestLocale() {
if (typeof window === 'undefined') return DEFAULT_LOCALE
return normalizeLocale(window.localStorage.getItem(LOCALE_STORAGE_KEY))
}
api.interceptors.request.use((config) => {
const auth = useAuthStore()
const url = config.url || ''
@@ -82,6 +89,8 @@ api.interceptors.request.use((config) => {
config.headers ||= {}
config.headers.Authorization = `Bearer ${auth.token}`
}
config.headers ||= {}
config.headers['Accept-Language'] = getRequestLocale()
return config
})