Secret exposed to the browser: NEXT_PUBLIC_OPENAI_API_KEY
.env:1app/api/ chat/ route.ts:3
.env line 1NEXT_PUBLIC_OPENAI_API_KEY=[REDACTED:secret_field]app/api/chat/route.ts line 3const openai = new OpenAI({ apiKey: process.env.NEXT_PUBLIC_OPENAI_API_KEY, dangerouslyAllowBrowser: true });Variables prefixed with NEXT_PUBLIC_ are bundled into the JavaScript every visitor downloads.
Drop the NEXT_PUBLIC_ prefix, use it server-side only (API route, server action, edge function) and rotate the key.