fix(docker): harden frontend runtime config

This commit is contained in:
2026-07-11 22:03:24 +02:00
parent 3d939426b1
commit 715de6649b
9 changed files with 75 additions and 11 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
import { backendBaseUrl as BASE } from "./runtime-config";
import { backendBaseUrl as BASE, joinBackendPath } from "./runtime-config";
export async function apiFetch<T>(path: string, init?: RequestInit): Promise<T> {
// Only declare a JSON content-type when we actually send a body. Body-less
@@ -10,7 +10,7 @@ export async function apiFetch<T>(path: string, init?: RequestInit): Promise<T>
if (init?.body != null && !("content-type" in headers) && !("Content-Type" in headers)) {
headers["content-type"] = "application/json";
}
const res = await fetch(`${BASE}${path}`, { ...init, headers });
const res = await fetch(joinBackendPath(BASE, path), { ...init, headers });
if (!res.ok) throw new Error(`${res.status} ${await res.text().catch(() => "")}`);
return res.status === 204 ? (undefined as T) : ((await res.json()) as T);
}