Spaces:
Runtime error
Runtime error
| import axios from 'axios'; | |
| const api = axios.create({ | |
| baseURL: '/api', | |
| withCredentials: true, | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| }); | |
| // Add a request interceptor to attach the token | |
| api.interceptors.request.use( | |
| (config) => { | |
| const token = localStorage.getItem('access_token'); | |
| if (token) { | |
| config.headers.Authorization = `Bearer ${token}`; | |
| } | |
| return config; | |
| }, | |
| (error) => { | |
| return Promise.reject(error); | |
| } | |
| ); | |
| export default api; |