diff --git a/app/src/hooks/httpClient/UseHttpClient.tsx b/app/src/hooks/httpClient/UseHttpClient.tsx new file mode 100644 index 0000000..107245b --- /dev/null +++ b/app/src/hooks/httpClient/UseHttpClient.tsx @@ -0,0 +1,24 @@ +import axios, { AxiosInstance, CreateAxiosDefaults } from 'axios'; + +export const useHttpClient = () => { + let config: CreateAxiosDefaults; + + if (import.meta.env.DEV) { + config = { + baseURL: import.meta.env.VITE_API_URL, + headers: { + 'Content-Type': 'application/json' + } + }; + } else { + config = { + headers: { + 'Content-Type': 'application/json' + } + }; + } + + const httpClient: AxiosInstance = axios.create(config); + + return httpClient; +};