Initial commit - Current state of vip-coordinator
This commit is contained in:
14
frontend/src/config/api.ts
Normal file
14
frontend/src/config/api.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
const DEFAULT_API_BASE =
|
||||
typeof window !== 'undefined'
|
||||
? window.location.origin
|
||||
: 'http://localhost:3000';
|
||||
|
||||
export const API_BASE_URL =
|
||||
import.meta.env.VITE_API_URL?.replace(/\/$/, '') || DEFAULT_API_BASE;
|
||||
|
||||
export const apiCall = (endpoint: string, options?: RequestInit) => {
|
||||
const url = /^https?:\/\//.test(endpoint)
|
||||
? endpoint
|
||||
: `${API_BASE_URL}${endpoint}`;
|
||||
return fetch(url, options);
|
||||
};
|
||||
Reference in New Issue
Block a user