Everything an app built with Lovable or Bolt does in the browser was first downloaded to that browser, including every key the code uses. Open the developer tools on any such app, search the scripts for sk_ or eyJ, and you will see what the app sends to its visitors. So will anyone else who looks.
That is not a flaw in itself. Some keys are made to be public. The question for an agency is not whether keys are visible, but which ones are, and whether anything else is holding the door that the key opens.
Keys that are meant to be public
A public key identifies the app to a service. It does not prove who the visitor is, and the service is built on the assumption that anyone can copy it. What keeps such a key harmless is a limit somewhere else.
- The Supabase publishable key, or the older anon key. Supabase's own documentation calls it safe to ship in a web page. It only reaches what the project's Row Level Security allows, so the protection is in the policies, not in the key. A table without good policies is open to anyone holding this key, which is everyone.
- The Stripe publishable key, which starts with
pk_live_orpk_test_. According to Stripe's guide to API keys, it is the only Stripe key meant for client-side code. It can start a payment flow, not read customers or move money. - A Google Maps key. It has to be in the page for the map to load, but Google's security guidance for Maps keys says to restrict it to the app's own address and to the APIs it needs. An unrestricted key lets others run their maps on your client's bill.
The pattern is the same each time: public key, limit elsewhere. When you find a public key, the check is not done. The next question is whether the limit is in place.
Keys that must never be there
A secret key acts on behalf of the account that owns it. Anyone who copies one from the browser can do what the key allows, from anywhere, without visiting the app again.
- The Supabase secret key (
sb_secret_) or the older service role key. It skips every Row Level Security policy. In the browser it means the whole database is readable and writable by anyone. - A Stripe secret or restricted key (
sk_live_,rk_live_). A secret key can make any request to the Stripe account: list customers, issue refunds, change products. - Keys for AI services, such as OpenAI (
sk-proj-) and Anthropic (sk-ant-). Every request is billed to the account that owns the key. OpenAI's own advice is never to deploy a key in browser or mobile code. - Keys for sending email, such as Resend or SendGrid. Whoever holds one can send mail from the client's verified domain, which is exactly what a convincing phishing mail needs.
- Tokens and private keys: GitHub tokens, AWS access keys, Slack tokens and anything that begins with
-----BEGIN PRIVATE KEY-----.
How secret keys end up in the browser
Rarely on purpose. The usual route is a prompt like "add an AI summary to the dashboard". The shortest path to a working feature is a call to the AI service straight from the page, with the key next to it, and the builder takes the shortest path unless told otherwise. The feature works in the preview, the client is happy, and the key ships with the next publish.
A second route is a naming convention. In a Vite project, which is what Lovable produces, any environment variable whose name starts with VITE_ is written into the browser code at build time. Lovable's guide to secrets says the same: those values are public, and real secrets belong in its secrets store. A secret named VITE_STRIPE_SECRET is not a secret.
The third route is the chat itself. A key pasted into a prompt "so the AI can test it" can end up written into a file, and from there into the build. In an app built through vibe coding, few people read the generated code closely enough to notice.
Where the call should go instead
A call that needs a secret key belongs on a server. In a Supabase app, that is an Edge Function: a small piece of server code that the browser calls instead of calling the service directly. The function reads the key from the project's secrets, checks that the user is allowed to do what they ask, makes the call and sends back only the result. The browser never sees the key.
The check matters as much as the move. A function that passes any request on to OpenAI has only moved the problem: the key is hidden, but anyone can still run up the bill through the function. It should at least require a signed-in user, and ideally limit how often each one may call it.
When you find a secret key in the code
Act in this order:
- Revoke the key at the provider and issue a new one. Removing it from the code is not enough. It has been public since the release that shipped it, it may be in cached copies, and it may be in a source map or the project's version history.
- Read the provider's usage log for the period the key was public. Unknown requests, unusual spend or new API calls are the signs that someone else found it first.
- Move the call to an Edge Function before putting the new key anywhere, so the next release does not ship it again.
- Tell the client, in plain words and with what you have already done. How to tell a client about a security finding has a structure for it.
A Stripe test key (sk_test_) is less urgent, because it cannot touch real payments. It still shows that the code calls Stripe from the browser, and the live key is usually one setting away.
Check after every release, not once
A key that was not in the code at launch can be there after next week's change. The search is mechanical: every script the app serves, matched against the formats the common services use. That makes it a good candidate for a check that runs on its own, every night, and says something only when a key turns up that was not there the day before. The files left on a live site deserve the same treatment, since a settings file on the server can hold every key at once.
The public keys need their own follow-up. A publishable Supabase key in the code is expected; the useful question is what it can reach. That is what the two-user test answers.