React
This commit is contained in:
16
client/src/api/axios.ts
Normal file
16
client/src/api/axios.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: "/api",
|
||||
})
|
||||
|
||||
api.interceptors.request.use((config)=>{
|
||||
const token = localStorage.getItem('token')
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
}
|
||||
|
||||
return config
|
||||
})
|
||||
|
||||
export default api
|
||||
Reference in New Issue
Block a user