How to secure a Bolt app before you deploy
Short answer
Secure a Bolt app by assuming every VITE_ variable is public, moving LLM, Stripe, and database-admin calls to a server or Edge Function, and setting Supabase RLS or Firebase rules before the first deploy. Bolt generates the project; the hosting provider serves the bundle. Search the production build for secret prefixes, keep .env out of the repo and off the web server, and scan the deployed URL while signed out.
Last updated · Sekrd Research
- Vite exposes every variable prefixed
VITE_to client code, and inlines the value into the bundle. Source: Vite’s env guide. - A Bolt project is the files you deploy. Security is the database rules, the bundle, and the host — not the chat transcript.
- Netlify and Vercel are not affected by the Next.js middleware bypass CVE-2025-29927. A Vite app you self-host still needs its own auth checks on the server.
The Bolt-shaped leak
Bolt (bolt.new) generates a project in the browser, often Vite plus React, and often wires Supabase or Firebase because that is the fastest way to get a database. The agent needs a key to make the chat feature work, so it creates VITE_OPENAI_API_KEY or VITE_SUPABASE_SERVICE_ROLE. Vite’s rule is the whole problem: anything with the VITE_ prefix is compiled into JavaScript and downloaded by every visitor. The preview works. The key is public the moment you deploy.
OpenAI’s key-safety guidance is explicit: never deploy a key in a browser or mobile app. The same applies to Anthropic, Gemini-on-the-paid-API, Stripe secret keys, and Supabase secret keys.
Checklist before you hit deploy
- Rename secrets so the client cannot see them. Delete
VITE_(andNEXT_PUBLIC_, if the project is Next) from every server secret. Put the value in the host’s server env — Netlify, Vercel, Cloudflare, a Supabase Edge Function secret — under a name with no client prefix. Which names are safe is the subject of the env-prefix guide. - Search the built files, not the chat.
npm run build
grep -R -n -E "sk-|sk-svcacct-|xai-|pplx-|fw_|sb_secret_|AIza" dist/
A hit on sb_publishable_ or a Firebase web API key can be legitimate. A hit on sb_secret_, sk-, or generativelanguage.googleapis.com next to an AIza key is not. If the key was ever deployed, rotate it. Removing the line does not pull it out of browsers and caches. The first-hour steps are in the leaked-key guide.
- Lock the database the agent created. For Supabase, run the RLS checklist and do not accept
USING (true)on user data. For Firebase, replace test-modeallow read, write: if trueand do not stop atif request.auth != null, which lets any signed-in user read every other user’s documents. The rules we look for are in the Firestore rules audit. - Do not ship
.env..env,.env.local, and.env.productionbelong in.gitignore. Confirm the host does not serve them: a static host that copies the whole project directory will. A real env file on the public URL is a critical finding; an HTML page that happens to mention the word API_KEY is not. - Put auth on the server that charges money or reads private rows. A button that hides the admin page is not authorization. The route that returns data, and the function that calls Stripe or the model, check the session themselves.
- Scan the deployed URL. A free scan reads the bundle the host actually serves. Run it after the production deploy, not only against the Bolt preview.
After the first users
Each new Bolt prompt can add a table, a bucket, or a VITE_ key. Re-run the bundle search and the database policy query when the agent touches either. If you want that on a schedule, Continuous Pro is on /pricing.
Frequently asked questions
How do I secure an app built with Bolt.new?
Treat every VITE_ variable as public, move API keys and the Supabase secret key to server-side env or Edge Function secrets, enable Row Level Security or Firebase rules before deploy, keep .env files out of the published site, and scan the production URL.
Are Bolt environment variables secret?
Only if they are not prefixed for the client. Vite inlines every VITE_ variable into the JavaScript bundle. Server secrets need a name without that prefix and a host that does not send them to the browser.
Does a Bolt preview prove the app is private?
No. The preview runs with your session and your local env. Visitors receive the built bundle and the public database key. Test signed out against the deployed URL.
Sources
Don't ship until you're sekrd
Run a free scan to find the vulnerabilities your AI missed.
Scan Your App Free