feat(api): use dynamic import for auth headers in fetchJson function
This commit is contained in:
+4
-2
@@ -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<T>(path: string, init?: RequestInit): Promise<T>
|
||||
? (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,
|
||||
|
||||
Reference in New Issue
Block a user