🚩 add something necessary

This commit is contained in:
2025-08-04 23:15:20 +07:00
parent 219a3bb6c7
commit 65cc862a55
6 changed files with 58 additions and 2 deletions

21
shared/lib/backendApi.ts Normal file
View File

@ -0,0 +1,21 @@
export const API_BASE_URL =
process.env.MAIN_BACKEND_API_URL ?? "http://localhost";
const apiFetch = async <T = unknown>(
path: string,
init?: RequestInit
): Promise<T> => {
const res = await fetch(`${API_BASE_URL}${path}`, {
...init,
headers: {
"Content-Type": "application/json",
...init?.headers,
},
cache: "no-store",
});
if (!res.ok) throw new Error(await res.text());
return res.json();
};
export default apiFetch;