add lang
key into data
provider
This commit is contained in:
@ -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
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user