The problem
Every AI feature needs credentials — a model provider, an embedding provider, a database. In a Next.js app, anything named NEXT_PUBLIC_ is compiled into JavaScript that every visitor downloads. One mislabelled variable publishes a key.
CodeForge: refuse to build
CodeForge talks to Supabase from the browser with a publishable key, and to Gemini and Groq only from the FastAPI backend. Before the frontend builds, it checks every public variable and fails the build if one holds a Supabase secret key or a service-role JWT:
export function validatePublicEnvironment(environment: Record<string, string | undefined>) {
for (const [name, value] of Object.entries(environment)) {
if (!name.startsWith("NEXT_PUBLIC_") || !value) continue;
let privileged = value.startsWith("sb_secret_");
try {
const claims = JSON.parse(Buffer.from(value.split(".")[1] ?? "", "base64url").toString("utf8"));
privileged ||= claims?.role === "service_role";
} catch { /* A public publishable key is not a JWT. */ }
if (privileged) throw new Error(`${name} must not contain a privileged Supabase key`);
}
}A second line of defence
A release script scans tracked and staged files for credential shapes — Supabase, GitHub, Google, Groq and OpenAI keys, private keys, AWS keys, database URLs with passwords — and decodes JWTs to catch service-role tokens under misleading names. It reports the file and the kind of secret, never the value. Its own docstring is honest about its limits: it is a release guard, not a guarantee.
Vericore: bring your own key, keep it in memory
Vericore's public-account branch asks each user for their own Groq key. Keys are held in per-account server memory, never persisted and never returned to the client; the trade-off is that users reconnect after a restart.
This site: no key at all
The playground here runs entirely in the visitor's browser over a public sample corpus, so there is no key to protect and no paid endpoint to abuse. The cost of that choice is honesty about what it is: a port without an LLM, labelled as such.
What can still go wrong
Pattern scans miss new key formats; build-time checks only cover the variables they know about; memory-only keys vanish on every deploy. None of these controls make a system secure on their own — they make one specific, common mistake much harder to ship.