fix: lazy-load BETTER_AUTH_SECRET para corrigir Docker build

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 <noreply@anthropic.com>
This commit is contained in:
Felipe Coutinho
2026-02-15 22:35:51 +00:00
parent 89366e5c8b
commit 98dd0f11e1
4 changed files with 16 additions and 13 deletions

View File

@@ -55,10 +55,10 @@ const deleteAccountSchema = z.object({
const VALID_FONTS = [ const VALID_FONTS = [
"ai-sans", "ai-sans",
"anthropic-sans", "anthropic-sans",
"fira-code", "fira-code",
"fira-sans", "fira-sans",
"geist", "geist",
"ibm-plex-mono", "ibm-plex-mono",
"inter", "inter",
"jetbrains-mono", "jetbrains-mono",
"reddit-sans", "reddit-sans",

View File

@@ -34,10 +34,8 @@ export function CategoryCell({
// Despesa: aumento é ruim (vermelho), diminuição é bom (verde) // Despesa: aumento é ruim (vermelho), diminuição é bom (verde)
// Receita: aumento é bom (verde), diminuição é ruim (vermelho) // Receita: aumento é bom (verde), diminuição é ruim (vermelho)
const isPositive = const isPositive = categoryType === "receita" ? isIncrease : isDecrease;
categoryType === "receita" ? isIncrease : isDecrease; const isNegative = categoryType === "receita" ? isDecrease : isIncrease;
const isNegative =
categoryType === "receita" ? isDecrease : isIncrease;
return ( return (
<Tooltip> <Tooltip>

View File

@@ -1,8 +1,13 @@
import crypto from "node:crypto"; import crypto from "node:crypto";
const JWT_SECRET = process.env.BETTER_AUTH_SECRET; function getJwtSecret(): string {
if (!JWT_SECRET) { const secret = process.env.BETTER_AUTH_SECRET;
throw new Error("BETTER_AUTH_SECRET is required. Set it in your .env file."); 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 ACCESS_TOKEN_EXPIRY = 7 * 24 * 60 * 60; // 7 days in seconds
const REFRESH_TOKEN_EXPIRY = 90 * 24 * 60 * 60; // 90 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 { function createSignature(data: string): string {
return crypto return crypto
.createHmac("sha256", JWT_SECRET) .createHmac("sha256", getJwtSecret())
.update(data) .update(data)
.digest("base64") .digest("base64")
.replace(/\+/g, "-") .replace(/\+/g, "-")

View File

@@ -1,5 +1,5 @@
import { import {
Fira_Code, Fira_Code,
Fira_Sans, Fira_Sans,
Geist, Geist,
IBM_Plex_Mono, IBM_Plex_Mono,
@@ -158,7 +158,7 @@ export const FONT_OPTIONS: FontOption[] = [
label: "Anthropic Sans", label: "Anthropic Sans",
variable: "var(--font-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", key: "fira-sans",
label: "Fira Sans", label: "Fira Sans",
@@ -211,7 +211,7 @@ const allFonts = [
reddit_sans, reddit_sans,
fira_sans, fira_sans,
ubuntu, ubuntu,
jetbrains_mono, jetbrains_mono,
fira_code, fira_code,
ibm_plex_mono, ibm_plex_mono,
]; ];