fix authProvider
for added custom
auth
This commit is contained in:
18
src/providers/data.ts
Normal file
18
src/providers/data.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import dataProvider from '@refinedev/simple-rest'
|
||||
import axios from 'axios'
|
||||
import {BACKEND_URL} from '../lib/constants'
|
||||
import {TOKEN_KEY} from '../authProvider'
|
||||
|
||||
const axiosInstance = axios.create()
|
||||
|
||||
axiosInstance.interceptors.request.use((config) => {
|
||||
const token = localStorage.getItem(TOKEN_KEY)
|
||||
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
}
|
||||
|
||||
return config
|
||||
})
|
||||
|
||||
export const customDataProvider = dataProvider(BACKEND_URL, axiosInstance)
|
Reference in New Issue
Block a user