From 05701dfdaaa8c02d2a9183772ebb63c1bfe8d84c Mon Sep 17 00:00:00 2001 From: tetiana zorii Date: Thu, 29 Jan 2026 23:11:58 -0500 Subject: [PATCH 1/2] fix(netlify): resolve AI API crash and 404 locale/theme issues AI fixes: - Extract getClientIp to separate file (avoid db import crash) - Add missing zod dependency to package.json 404 page fixes: - Use NEXT_LOCALE cookie for locale detection on Netlify - Add theme detection script in root layout - Update styling with hero background and gradient text --- frontend/app/api/ai/explain/route.ts | 5 ++- frontend/app/layout.tsx | 19 ++++++++++ frontend/app/not-found.tsx | 56 ++++++++++++++++++---------- frontend/lib/security/client-ip.ts | 48 ++++++++++++++++++++++++ frontend/package.json | 3 +- frontend/proxy.ts | 5 +++ 6 files changed, 114 insertions(+), 22 deletions(-) create mode 100644 frontend/lib/security/client-ip.ts diff --git a/frontend/app/api/ai/explain/route.ts b/frontend/app/api/ai/explain/route.ts index 551561c6..115ce801 100644 --- a/frontend/app/api/ai/explain/route.ts +++ b/frontend/app/api/ai/explain/route.ts @@ -7,7 +7,7 @@ import { createExplainPrompt, type ExplanationResponse, } from '@/lib/ai/prompts'; -import { getClientIp } from '@/lib/security/rate-limit'; +import { getClientIp } from '@/lib/security/client-ip'; const rateLimiter = new Map(); const MAX_REQUESTS_PER_WINDOW = 10; @@ -94,6 +94,9 @@ export async function POST(request: NextRequest) { const apiKey = process.env.GROQ_API_KEY; if (!apiKey) { console.error('GROQ_API_KEY is not configured'); + console.error('Available env vars starting with GROQ:', + Object.keys(process.env).filter(k => k.startsWith('GROQ')) + ); return NextResponse.json( { error: 'AI service not configured', code: 'SERVICE_UNAVAILABLE' }, { status: 503 } diff --git a/frontend/app/layout.tsx b/frontend/app/layout.tsx index c92fb3b7..e5ee2c7a 100644 --- a/frontend/app/layout.tsx +++ b/frontend/app/layout.tsx @@ -34,6 +34,25 @@ export default function RootLayout({ }>) { return ( + +