Files
textbee/web/lib/httpClient.ts
2023-10-16 10:15:17 +03:00

17 lines
400 B
TypeScript

import axios from 'axios'
import { LOCAL_STORAGE_KEY } from '../shared/constants'
const httpClient = axios.create({
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL,
})
httpClient.interceptors.request.use((config) => {
const token = localStorage.getItem(LOCAL_STORAGE_KEY.TOKEN)
if (token) {
config.headers.Authorization = `Bearer ${token}`
}
return config
})
export default httpClient