Load env var for api url into ui for production

This commit is contained in:
2025-04-14 23:37:47 -04:00
parent 9ad87fbac5
commit c2e9e098ed
5 changed files with 9 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
const baseUrl = import.meta.env.VITE_API_URL || 'http://localhost:8080/api';
// @ts-expect-error The window.__CONFIG__ only exists in production
const baseUrl = window.__CONFIG__?.API_URL || import.meta.env.VITE_API_URL || 'http://localhost:8080/api';
export async function getRequest(endpoint: string, params: Record<string, any> = {}): Promise<Response> {
Object.keys(params).forEach((key) => params[key] === undefined && delete params[key]);