chore: initial commit with Phase 0 setup

This commit is contained in:
OG T
2026-06-06 22:55:45 +08:00
commit 9e79e58f87
56 changed files with 16088 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
export async function proxyToBackend(
endpoint: string,
payload: any,
baseUrl?: string,
apiKey?: string
) {
if (!baseUrl) throw new Error("API_BASE_URL is not configured.");
const url = `${baseUrl.replace(/\/$/, "")}${endpoint}`;
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${apiKey || ""}`,
},
body: JSON.stringify(payload),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`Backend error (${response.status}): ${text}`);
}
return response.json();
}