From 98dd0f11e1dd74ccae3dc02fd50f940e071537ca Mon Sep 17 00:00:00 2001 From: Felipe Coutinho Date: Sun, 15 Feb 2026 22:35:51 +0000 Subject: [PATCH] fix: lazy-load BETTER_AUTH_SECRET para corrigir Docker build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Validação eager do secret no top-level do módulo causava falha no build Docker porque a env var não existe em build-time. Movido para função getJwtSecret() chamada em runtime. Co-Authored-By: Claude Opus 4.6 --- app/(dashboard)/ajustes/actions.ts | 4 ++-- components/relatorios/category-cell.tsx | 6 ++---- lib/auth/api-token.ts | 13 +++++++++---- public/fonts/font_index.ts | 6 +++--- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/(dashboard)/ajustes/actions.ts b/app/(dashboard)/ajustes/actions.ts index e45143e..73760db 100644 --- a/app/(dashboard)/ajustes/actions.ts +++ b/app/(dashboard)/ajustes/actions.ts @@ -55,10 +55,10 @@ const deleteAccountSchema = z.object({ const VALID_FONTS = [ "ai-sans", "anthropic-sans", -"fira-code", + "fira-code", "fira-sans", "geist", -"ibm-plex-mono", + "ibm-plex-mono", "inter", "jetbrains-mono", "reddit-sans", diff --git a/components/relatorios/category-cell.tsx b/components/relatorios/category-cell.tsx index a47b44b..229d39c 100644 --- a/components/relatorios/category-cell.tsx +++ b/components/relatorios/category-cell.tsx @@ -34,10 +34,8 @@ export function CategoryCell({ // Despesa: aumento é ruim (vermelho), diminuição é bom (verde) // Receita: aumento é bom (verde), diminuição é ruim (vermelho) - const isPositive = - categoryType === "receita" ? isIncrease : isDecrease; - const isNegative = - categoryType === "receita" ? isDecrease : isIncrease; + const isPositive = categoryType === "receita" ? isIncrease : isDecrease; + const isNegative = categoryType === "receita" ? isDecrease : isIncrease; return ( diff --git a/lib/auth/api-token.ts b/lib/auth/api-token.ts index 2b6e838..4460e28 100644 --- a/lib/auth/api-token.ts +++ b/lib/auth/api-token.ts @@ -1,8 +1,13 @@ import crypto from "node:crypto"; -const JWT_SECRET = process.env.BETTER_AUTH_SECRET; -if (!JWT_SECRET) { - throw new Error("BETTER_AUTH_SECRET is required. Set it in your .env file."); +function getJwtSecret(): string { + const secret = process.env.BETTER_AUTH_SECRET; + if (!secret) { + throw new Error( + "BETTER_AUTH_SECRET is required. Set it in your .env file.", + ); + } + return secret; } const ACCESS_TOKEN_EXPIRY = 7 * 24 * 60 * 60; // 7 days in seconds const REFRESH_TOKEN_EXPIRY = 90 * 24 * 60 * 60; // 90 days in seconds @@ -59,7 +64,7 @@ function base64UrlDecode(str: string): string { */ function createSignature(data: string): string { return crypto - .createHmac("sha256", JWT_SECRET) + .createHmac("sha256", getJwtSecret()) .update(data) .digest("base64") .replace(/\+/g, "-") diff --git a/public/fonts/font_index.ts b/public/fonts/font_index.ts index 4e2ad25..03c9719 100644 --- a/public/fonts/font_index.ts +++ b/public/fonts/font_index.ts @@ -1,5 +1,5 @@ import { -Fira_Code, + Fira_Code, Fira_Sans, Geist, IBM_Plex_Mono, @@ -158,7 +158,7 @@ export const FONT_OPTIONS: FontOption[] = [ label: "Anthropic Sans", variable: "var(--font-anthropic-sans)", }, -{ key: "fira-code", label: "Fira Code", variable: "var(--font-fira-code)" }, + { key: "fira-code", label: "Fira Code", variable: "var(--font-fira-code)" }, { key: "fira-sans", label: "Fira Sans", @@ -211,7 +211,7 @@ const allFonts = [ reddit_sans, fira_sans, ubuntu, -jetbrains_mono, + jetbrains_mono, fira_code, ibm_plex_mono, ];