How do I check that my AI-built app doesn't expose secret keys before publishing it?
Before publishing an AI-built app, search the code for keys, make sure .env never reached git and inspect the compiled build in the browser. Secret keys belong on a server, and any leaked key must be rotated.
Before publishing, rule out AI app exposed API keys: search the code for keys, confirm the .env file isn't in git, and open the compiled build in the browser to look for secrets. Anything in the frontend is public. Use AI, payment and database keys only from a server, and rotate any key that already leaked.
Why an AI-built app can have exposed keys
Lovable, Bolt, v0, Cursor or Claude Code generate code fast, but sometimes they put the key wherever it works, not where it's safe. It's common to find an API key written directly in a component, a .env file pushed to the repository, or a public variable with a secret inside. This checklist helps you catch it before your app goes live on the internet.
Pre-publish checklist
- Search the code for keys. Use your editor's global search or run this in the terminal:
git grep -n -i -E "sk-|api_key|apikey|secret|password|token"Review every result. If you see a real value (a long, random string) written in the code, take it out.
- Check the .env file and the git history. Make sure
.gitignoreincludes.envand check whether it ever made it into a commit:
git log --all --oneline -- .envIf a key was ever in a commit or in a public repository, consider it compromised. Deleting it from the file isn't enough, because it's still in the history. Generate a new one with the provider and disable the old one.
- Understand what ends up in the browser. On a static site, everything that goes into the build gets downloaded by the visitor. Variables with a public prefix, such as
VITE_in Vite orNEXT_PUBLIC_in Next.js, end up inside the JavaScript. Only public values belong there, for example the Supabase URL and anon key protected with RLS. Never put AI keys, payment keys or database passwords there. - Inspect the compiled app. Open your app in the browser and go to the developer tools. In the Network tab, review the requests and their headers. In the JS files, use Ctrl+F to search for the same patterns from step 1. If you find a secret key there, anyone can find it.
- Move secret calls to the server. Create a backend or a server function in Node.js (for example with Express or Hono) that calls the API using a server environment variable. Your frontend calls your backend, never the API directly with the key.
- Ask your AI to review it. A short prompt you can use:
Review this entire project for keys, tokens or passwords written in the code or exposed to the browser (including VITE_ or NEXT_PUBLIC_ variables). List each finding with file and line, and propose how to move it to a server environment variable in Node.js.Use the answer as support. The final review is still yours.
Where each type of value goes
| Type of value | Can it go in the frontend? | Where to store it |
|---|---|---|
| Supabase URL and anon key (with RLS enabled) | Yes | Variable with a public prefix |
| AI API key (OpenAI, Anthropic, etc.) | No | Node.js server environment variable |
| Payment gateway keys (secret) | No | Node.js server environment variable |
Database password or URL (for example DATABASE_URL) | No | Server only |
| Supabase service key | No | Server only |
If you use Supabase, first enable RLS before publishing your Lovable or Bolt app. Without RLS, the anon key is no longer safe.
How to store keys in Dongee Live
Dongee Live, Dongee's hosting for AI-built apps, publishes apps made with ChatGPT, Lovable, Bolt, v0, Claude Code, Codex, Cursor or VS Code. You can define your own environment variables on every plan, including Live Free, and Node.js apps run with their backend. Each app also comes with a MySQL database available in the DATABASE_URL variable, which should only be read from the server.
One important detail: if you publish from GitHub, Live environment variables do reach the build of a static site (for example, with Vite). That's useful for setting the Supabase URL, but it also means any variable with a public prefix ends up visible in the final JavaScript. That's why secret keys should only be used in an app with a Node.js server. If you're not sure which case applies to you, check whether your Lovable app is static or needs a server. For the repository workflow, see how to publish a Bolt app from GitHub on every push.
What Live does and doesn't do
Live maintains the operating system and the web server, restarts the app if it crashes, and issues and renews HTTPS. It doesn't review your code or detect exposed keys: that review is up to you before publishing. It's also not the right option if your backend is in Python, uses Docker or is PHP/WordPress. For Python and Docker there's Dongee Cloud, and for PHP and WordPress, Dongee's cPanel hosting. Live only works with MySQL databases, although you can connect external services such as Supabase.
Frequently asked questions
Is the Supabase anon key secret?
No. It's meant to go in the frontend, but it's only safe if your tables have RLS enabled. The service key is secret and must never reach the browser.
What do I do if I already published a key?
Generate a new one with the provider, disable the old one and move the key's usage to the server. Deleting it from the code doesn't help if it was already in a commit or a public build.
Can I call an AI API directly from the browser?
It's not recommended. The key would be visible to anyone. Make the call from a Node.js backend and, as an extra measure, limit your API key to certain AI models.
Is adding .env to .gitignore enough?
It only protects future commits. If the file was already pushed, it's still in the history and you must change the keys it contained.
Does Live Free allow environment variables?
Yes. Live Free (0 USD) allows your own environment variables and one Node.js app with its backend included.
Summary
Checking your keys takes a few minutes: search the code, clean the history, inspect the build and keep secrets on the server. Once everything is in order, you can publish your app on Dongee Live.
Comenta lo que quieras
Unete a la charla
Solo ingresa tu email