Secret in a public env var
This is how the comment reads inline, under the flagged line.
Why it matters
Public env prefixes inline the value into client JavaScript. A secret there is published.
What to do
Keep the secret server-side and call it through your own API.
Examples
process.env.NEXT_PUBLIC_PAYMENTS_SECRET
process.env.PAYMENTS_SECRET // server only
What it catches
It reads a pattern on each line, aware of strings and comments. Languages: Any file. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
const s = process.env.NEXT_PUBLIC_PAYMENTS_SECRET;
Left alone
const k = process.env.NEXT_PUBLIC_PAYMENTS_PUBLISHABLE_KEY;
Research
Secrets in public env vars (`NEXT_PUBLIC_*`, `VITE_*`). Anything with a public prefix ships to every browser.
- skill: vibe-code-doctor
- skill: react-doctor
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"client-exposed-secret"
],
"severity": {
"client-exposed-secret": "low"
}
}
}
NEXT_PUBLIC_PAYMENTS_SECRETis bundled into the browser build, where anyone can read it.