move api url to .env
This commit is contained in:
1
client/.env
Normal file
1
client/.env
Normal file
@@ -0,0 +1 @@
|
|||||||
|
REACT_APP_API_URL=http://localhost:5000
|
||||||
@@ -14,5 +14,6 @@ export const createApiClient =
|
|||||||
...rest,
|
...rest,
|
||||||
};
|
};
|
||||||
|
|
||||||
return fetch(host + input, customInt);
|
const host = process.env.REACT_APP_API_URL ?? ""
|
||||||
|
return fetch(`${host}/${input}`, customInt);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
const host = "http://localhost:5000/";
|
|
||||||
|
|
||||||
export const createSWRFetcher =
|
export const createSWRFetcher =
|
||||||
(token: string | null) => async (input: RequestInfo | URL, init?: RequestInit) => {
|
(token: string | null) => async (input: RequestInfo | URL, init?: RequestInit) => {
|
||||||
const { headers, ...rest } = init ?? {};
|
const { headers, ...rest } = init ?? {};
|
||||||
@@ -13,6 +11,7 @@ export const createSWRFetcher =
|
|||||||
...rest,
|
...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();
|
return await res.json();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user