diff --git a/taskncoffee-app/src/apiv1/client.js b/taskncoffee-app/src/apiv1/client.js new file mode 100644 index 0000000..688fa99 --- /dev/null +++ b/taskncoffee-app/src/apiv1/client.js @@ -0,0 +1,23 @@ +import axios from 'axios'; +import { API_BASE_URL, API_V1_PREFIX } from './ApiSources'; + + +const client = axios.create({ + baseURL: `${API_BASE_URL}${API_V1_PREFIX}`, + timeout: 10000, + headers: { + 'Content-Type': 'application/json', + }, + withCredentials: true, +}); + +client.interceptors.request.use( + (config) => { + const token = localStorage.getItem('access_token'); + if (token) { + config.headers.Authorization = `Bearer ${token}`; + } + return config; + }, +); +export default client; \ No newline at end of file