diff --git a/frontend/src/api/index.js b/frontend/src/api/index.js new file mode 100644 index 0000000..0e0cf32 --- /dev/null +++ b/frontend/src/api/index.js @@ -0,0 +1,18 @@ +import axios from 'axios' + +const api = axios.create({ + baseURL: '/api/v1', + headers: { + 'Content-Type': 'application/json' + } +}) + +api.interceptors.request.use((config) => { + const token = localStorage.getItem('token') + if (token) { + config.headers.Authorization = `Bearer ${token}` + } + return config +}) + +export default api