From 0927815e76af837f2c83fba9fe72d658db0fae42 Mon Sep 17 00:00:00 2001 From: "dev.daminik00" Date: Sun, 24 Aug 2025 23:34:41 +0200 Subject: [PATCH] fix build --- src/shared/api/httpClient.ts | 2 +- src/shared/auth/token.ts | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/shared/api/httpClient.ts b/src/shared/api/httpClient.ts index 8e5e11e..1844085 100644 --- a/src/shared/api/httpClient.ts +++ b/src/shared/api/httpClient.ts @@ -85,7 +85,7 @@ class HttpClient { accessToken = await getServerAccessToken(); } else { try { - const { getClientAccessToken } = await import("../auth/clientToken"); + const { getClientAccessToken } = await import("../auth/token"); accessToken = getClientAccessToken(); } catch { // ignore diff --git a/src/shared/auth/token.ts b/src/shared/auth/token.ts index 7450379..a04cee5 100644 --- a/src/shared/auth/token.ts +++ b/src/shared/auth/token.ts @@ -1,5 +1,17 @@ -import { cookies } from "next/headers"; - +// Server-side token functions (only for Server Components) export async function getServerAccessToken() { + const { cookies } = await import("next/headers"); return (await cookies()).get("accessToken")?.value; } + +// Client-side token functions +export function getClientAccessToken(): string | undefined { + if (typeof window === "undefined") return undefined; + + const cookies = document.cookie.split(';'); + const accessTokenCookie = cookies.find(cookie => + cookie.trim().startsWith('accessToken=') + ); + + return accessTokenCookie?.split('=')[1]; +}