diff --git a/frontend/lib/api.ts b/frontend/lib/api.ts index a9625d09..db7fa518 100644 --- a/frontend/lib/api.ts +++ b/frontend/lib/api.ts @@ -2,7 +2,12 @@ const API_BASE = process.env.NEXT_PUBLIC_API_URL_INTERNAL || 'http://recipe-api:8080'; export async function fetchJson(path: string, init?: RequestInit): Promise { - const res = await fetch(`${API_BASE}${path}`, { + // Använd alltid relativ path i webbläsaren för att undvika mixed content + const url = typeof window === 'undefined' + ? (path.startsWith('http') ? path : `${API_BASE}${path}`) + : path; + + const res = await fetch(url, { ...init, cache: 'no-store', headers: {