You asked Bolt to connect your app to an AI provider, a payment service or an email sender, and it asked you for an API key. That is a long password your app uses to prove who it is to another service. You pasted it in.
Was that okay? It depends on which key, and where it ended up. This post gives you a way to tell.
Two kinds of keys
Services hand out two kinds of keys:
- Public keys are made to be seen by everyone, so they can sit in a web page.
- Secret keys must stay hidden, because they open everything on your account.
Stripe's documentation is a clear example. A publishable key (starting pk_) can go in front-end code, the part of your app that visitors download and see. A secret key (starting sk_) has unrestricted permissions and must stay on your back end, the part of your app that runs on the service's computers, where visitors cannot look. Supabase, the service that keeps your app's data, draws the same line between its publishable key and its secret key.
So putting a Supabase publishable key or a Stripe publishable key in your app is normal. Putting any of these in code that every visitor downloads is not:
- an AI provider key
- a Stripe secret key
- a Supabase secret key
- an email provider key
Anyone who opens the page in a browser (the program people use to open websites, such as Chrome or Safari) can read what it received, including a key.
Why "it is in an environment variable" is not enough
An environment variable is one named setting, kept in a settings file where an app stores its keys. Bolt apps are usually built with Vite, a tool that packages the app.
Vite's documentation says that any variable whose name starts with VITE_ is included in the code sent to the browser and is visible to anyone using the app. It advises against giving that prefix to sensitive values, and says VITE_ variables should not contain things like API keys.
Many people feel safe because the key sits in a settings panel or a settings file (an env file), then name it with the VITE_ prefix and publish it to the world.
Bolt's support glossary describes environment variables as configuration values such as API keys kept outside your code, and warns that putting sensitive values directly in project files exposes them. That is useful, but the prefix still decides whether the value reaches every visitor.
The keys a Bolt app usually holds, sorted
Most Bolt apps connect to the same few services. Here is how to sort the keys you will find, by the names the providers give them.
- **Supabase publishable key**, starting with
sb_publishable_, or the anon key on older projects. Made for the browser. Supabase's documentation says it is safe to expose when Row Level Security, the database's own rules about who may read each record, is turned on for your tables. - **Supabase secret key**, starting with
sb_secret_, or the service_role key on older projects. Never in the browser. Supabase's documentation says it goes around those rules and reaches everything, and that an attacker can use a copied one from other tools even though Supabase refuses it when it is sent from a browser. - **Stripe publishable key**, starting with
pk_. Made for the browser. - **Stripe secret key or restricted key**, starting with
sk_orrk_. Server only. Stripe's documentation says a secret key can perform any API request on your account. - **Any other provider's key** (AI, email, maps, analytics). Read the provider's dashboard. If it does not say the key is made for browsers, treat it as secret.
Older Supabase keys are long strings that start with eyJ, and the anon and service_role keys look alike. To tell them apart in your live code, copy the last ten characters of your service_role key from the Supabase dashboard and search for those.
How to check your own app in five minutes
- Open your published app in a browser, open the developer tools Sources tab (or View Source), and search for "
sk_", "rk_", "sb_secret_", "service_role", "secret" and the name of any service you connected. Developer tools are a panel built into the browser that shows the code it received. - Look at your environment variable names. Any secret with a
VITE_prefix is exposed. - Check that
.envfiles are not committed to your repository. A repository is the folder that holds your app's code and its history, often kept on GitHub, and to commit is to save a change into that history. GitHub secret scanning looks for credentials across your Git history and alerts you if it finds one. - Look at your payment and AI calls. If the page calls the provider directly with a secret, move that call to a server-side function.
Where secret keys should live
Keys that must stay secret belong on the service's computers, where visitors cannot look:
- a serverless function (a small piece of code that runs only when called)
- an edge function (the same, run close to the visitor)
- your host's secrets store
Your page then calls your function, and your function calls the provider. Vite's documentation suggests this pattern: a backend server or serverless or edge functions for production secrets.
A practical way to ask Bolt for this:
Prompt
Move every call that uses a secret key into a server-side function, and make the page call that function instead. Do not use a VITE_ prefix for any secret.Then re-check the page source as above, because a request is not proof.
If a secret key has already been exposed
Assume it has been copied.
- Create a new key and put it where only your server can read it.
- Turn the old one off.
- Check the provider's usage logs for activity you do not recognise.
GitHub's documentation says to rotate an affected credential immediately, and notes that cleaning Git history is slow and often unnecessary once the credential is revoked.
Questions people ask
Is my Supabase anon key a secret?
No, it is made to be seen by everyone. But your table rules must be right, because that key is the one every visitor holds. A table rule is the database's own rule about who may read or change each record.
Does a private repository make a key safe?
No. The key is still sent to every visitor in the built page.
Is a test key a problem?
A test-mode key is far less risky than a live one, but treat it the same way so the habit carries over to launch day.
A note on mobile and desktop apps
The same rule applies outside the browser. Code shipped inside a phone app or a desktop app can be unpacked by anyone who downloads it, so a secret key inside it is as exposed as one on a web page. Route those calls through a server you control as well.
What to write down after the fix
Keep a short list of every service your app talks to, which key each one uses, and where that key lives. When something goes wrong, or when a teammate joins, that page saves hours.
Next to each key, note:
- whether it is public by design or secret
- the date you last replaced it
Replacing secret keys every few months is a cheap habit that limits how long any old copy stays useful. It also helps to give each key the smallest power that does the job. Where a service lets you create a restricted key, use one, so a leak can do less damage.