What goes wrong
Treat any secret that ever reached your browser code or your git history as public. AI tools often paste API keys straight into the code to make a feature work. Next.js copies every variable that starts with NEXT_PUBLIC_ into the JavaScript sent to the browser, and Vite does the same with VITE_. Git keeps every old version of every file, so a key removed today is still in the history.
How to check
- List every key the app uses: payments, email, AI providers, database.
- Ask your developer which ones carry a public prefix, and why.
- Open your live site, view the loaded scripts and search for the start of each secret key.
- Ask your developer to run a secret scanner over the full git history.
How to fix
Move secrets into server-only environment variables. Treat any key that ever reached git or the browser as public: create a new one, deploy, then revoke the old one.
What good looks like: No secret key appears in the loaded scripts, the scanner finds none in the history, and every key that leaked has been replaced.
Source: Next.js: Environment variables
What we saw in an audit
In one audit, a local environment file had been committed to git history, and the keys in it had not yet been rotated.
Sample report based on a real audit. Client details and figures changed.
Rather have someone run this check for you?
Get the whole app checked