add lang key into data provider

This commit is contained in:
maxim
2025-03-28 02:19:55 +03:00
parent 31886eaf0a
commit 754569b41d
2 changed files with 58 additions and 4 deletions

View File

@ -2,16 +2,23 @@ import dataProvider from '@refinedev/simple-rest'
import axios from 'axios'
import {BACKEND_URL} from '../lib/constants'
import {TOKEN_KEY} from '../authProvider'
import Cookies from 'js-cookie'
const axiosInstance = axios.create()
axiosInstance.interceptors.request.use((config) => {
// Добавляем токен авторизации
const token = localStorage.getItem(TOKEN_KEY)
if (token) {
config.headers.Authorization = `Bearer ${token}`
}
// Добавляем язык в кастомный заголовок
const lang = Cookies.get('lang') || 'ru'
config.headers['X-Language'] = lang // или 'Accept-Language'
// console.log('Request headers:', config.headers)
return config
})