From 07b7dc0d0377585233639d335a8088ccf5b9be9e Mon Sep 17 00:00:00 2001 From: mehditorabiv Date: Thu, 1 Aug 2024 12:50:47 +0300 Subject: [PATCH] update axios instance --- .env | 1 + src/api/index.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..2092a11 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +VITE_API_BASE_URL=https://onchain.togethercrew.de/api/v1/ \ No newline at end of file diff --git a/src/api/index.ts b/src/api/index.ts index 89bd8c0..15ec0e3 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,7 +1,16 @@ +// src/api/index.ts import axios from 'axios'; -export const client = axios.create({ - baseURL: '', +const baseURL = import.meta.env.VITE_API_BASE_URL; + +if (!baseURL) { + throw new Error( + 'VITE_API_BASE_URL is not defined in your environment variables' + ); +} + +export const api = axios.create({ + baseURL, headers: { 'Content-Type': 'application/json', },