diff --git a/client/.env b/client/.env new file mode 100644 index 0000000..babc50e --- /dev/null +++ b/client/.env @@ -0,0 +1 @@ +REACT_APP_API_URL=http://localhost:5000 \ No newline at end of file diff --git a/client/src/utils/apiFetch.ts b/client/src/utils/apiFetch.ts index 24fa205..8a1f6c1 100644 --- a/client/src/utils/apiFetch.ts +++ b/client/src/utils/apiFetch.ts @@ -14,5 +14,6 @@ export const createApiClient = ...rest, }; - return fetch(host + input, customInt); + const host = process.env.REACT_APP_API_URL ?? "" + return fetch(`${host}/${input}`, customInt); }; diff --git a/client/src/utils/swrFetcher.ts b/client/src/utils/swrFetcher.ts index 5601f2c..17bc122 100644 --- a/client/src/utils/swrFetcher.ts +++ b/client/src/utils/swrFetcher.ts @@ -1,5 +1,3 @@ -const host = "http://localhost:5000/"; - export const createSWRFetcher = (token: string | null) => async (input: RequestInfo | URL, init?: RequestInit) => { const { headers, ...rest } = init ?? {}; @@ -13,6 +11,7 @@ export const createSWRFetcher = ...rest, }; - const res = await fetch(host + input, customInt); + const host = process.env.REACT_APP_API_URL ?? "" + const res = await fetch(`${host}/${input}`, customInt); return await res.json(); };