Secret exposed to the browser: NEXT_PUBLIC_OPENAI_API_KEY
.env:1
Your OpenAI key is in a variable whose name starts with NEXT_PUBLIC_, and Next.js copies those into the code every visitor's browser downloads. Anyone can take the key from there and spend your OpenAI credit. Create a new key, delete this one in OpenAI, and save the new one as OPENAI_API_KEY, without the prefix.
.env line 1NEXT_PUBLIC_OPENAI_API_KEY=[REDACTED:secret_field]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.