From 28e938e66e4e8a0ef2b077c2cb4e6ff982bad710 Mon Sep 17 00:00:00 2001 From: Nils-Johan Gynther Date: Fri, 17 Apr 2026 20:29:52 +0200 Subject: [PATCH] feat(api): use dynamic import for auth headers in fetchJson function --- frontend/lib/api.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/lib/api.ts b/frontend/lib/api.ts index 1d7ff37e..b36c5864 100644 --- a/frontend/lib/api.ts +++ b/frontend/lib/api.ts @@ -1,5 +1,4 @@ import { redirect } from 'next/navigation'; -import { getAuthHeaders } from './auth-headers'; const API_BASE = process.env.NEXT_PUBLIC_API_URL_INTERNAL || 'http://recipe-api:8080'; @@ -11,7 +10,10 @@ export async function fetchJson(path: string, init?: RequestInit): Promise ? (path.startsWith('http') ? path : `${API_BASE}${path}`) : path; - const authHeaders = isServer ? await getAuthHeaders() : {}; + // Dynamisk import så att auth-headers inte bundlas till klienten + const authHeaders = isServer + ? await (await import('./auth-headers')).getAuthHeaders() + : {}; const res = await fetch(url, { ...init,