Skip to content
Product Building

Your Bolt Prototype Is Leaking Live API Keys

AI builders like Bolt.new bypass backends by hardcoding your secrets into the browser. Here is how to find and secure them.

Developer inspecting a browser dev-tools network tab on a large monitor, showing an exposed API key in a code panel.
Shreyansh Doshi Founder, Samvara Published Reviewed Read 7 min

What You Need to Know

AI code generators like Bolt.new often inject sensitive API keys directly into the client-side JavaScript bundle to make the prototype work immediately. To secure the app, you must move all API calls to a secure server-side environment before rotating the exposed keys.

At a Glance

Core Risk
AI builders inject live API keys into public JavaScript.
Toxic Keys
OpenAI, Stripe Secret, AWS, SendGrid.
Safe Keys
Stripe Publishable, Supabase Anon, Google Analytics.
The Fix
Move sensitive API calls to server-side Edge Functions.
Hardening Cost
Professional review starts at £199.

Best For

  • B2B founders who have prototyped operations software using AI builders.
  • Operations leaders auditing internal tools before deploying them to staff.
  • Teams preparing to connect real billing or customer data to a vibe-coded MVP.

Not For

  • ×Consumer app developers building non-commercial side projects.
  • ×Engineers already running strict CI/CD pipelines with dedicated backends.

Key Takeaways

  • AI coding agents often hardcode secret API keys into the browser bundle to avoid building a backend.
  • Keys prefixed with VITE_ or NEXT_PUBLIC_ are visible to anyone who inspects your web page.
  • Replacing an exposed key without changing the application architecture simply exposes the new key.
  • Sensitive calls (Stripe Secret, OpenAI, AWS) must be routed through a secure server-side proxy or edge function.

You spent the weekend in Bolt.new or Lovable. You described the B2B quoting engine you needed, attached a spreadsheet of your pricing rules, and within hours, you had a working prototype. It calls OpenAI to parse customer emails and uses Stripe to generate payment links. You are ready to share it with your team on Monday.

But to make that prototype work instantly, the AI coding agent took a shortcut that makes it entirely unsuited for live operations: it dumped your private API keys directly into the browser.

AI agents want the path of least resistance. Building a secure backend to route requests takes time and architectural planning. Instead, tools like Bolt and Lovable often configure front-end frameworks to bundle your secret keys straight into the compiled JavaScript. Anyone who right-clicks and inspects your web page now has full access to your company's Stripe account, your AWS environment, or your OpenAI billing limit.

Deploying an AI-generated app without auditing the client bundle is a critical operational risk. Here is how to find out if your prototype is leaking secrets, which keys actually matter, and why hitting the 'rotate' button in your vendor dashboard solves nothing until you fix the architecture.

The Architecture of a Vibe-Coded Leak

Modern front-end frameworks like React, Next.js, and Vite require specific prefixes to expose environment variables to the browser—such as NEXT_PUBLIC_ or VITE_. This mechanism exists so you can safely pass public identifiers, like a Google Maps public key, to the client.

AI coding agents do not understand business risk. When they encounter an error saying "Missing API Key" while trying to connect to OpenAI, their immediate solution is often to prefix your secret key with VITE_ so the browser can access it directly.

The moment that happens, your secret key ceases to be a secret. It is packaged into the bundle.js file that gets downloaded by every single user who visits your application. You cannot hide it by right-clicking and disabling "View Source." Automated bots constantly scrape newly published websites specifically looking for exposed sk-proj (OpenAI) and sk_live (Stripe) strings to exploit.

If you plug your corporate keys into an AI builder and publish the result, you are handing those keys to the public internet.

How to Check Your App for Exposed Secrets

You do not need to be a developer to check if your application is leaking keys. You just need a Google Chrome browser.

  1. Open your published prototype in Chrome.
  2. Right-click anywhere on the page and select Inspect.
  3. Click on the Network tab at the top of the developer tools panel.
  4. Reload the page.
  5. Click the Search icon (a magnifying glass) inside the Network tab.
  6. Search for the common prefixes of the API keys you provided to the AI.

If you use OpenAI, search for sk-proj or sk-ant. If you use Stripe, search for sk_live or sk_test. If you use SendGrid, search for SG..

If your search returns a hit inside a JavaScript file, your key is exposed. Anyone with basic technical knowledge can extract it, impersonate your application, and rack up tens of thousands of pounds in usage fees on your corporate card.

Safe vs. Unsafe Keys in the Browser

Not every string in your .env file needs to be kept secret. Understanding the difference prevents you from wasting time securing keys that are designed to be public.

Keys Designed for the Browser (Safe to Expose)

Some keys are purely identifiers. They tell a third-party service which account is making the request, but they do not grant permission to spend money or access secure data on their own.

  • Stripe Publishable Keys (pk_live_... or pk_test_...): These are meant to be embedded in your front-end. They allow Stripe to safely tokenize credit card data in the browser. They cannot be used to issue refunds, create charges, or pull customer data.
  • Supabase Anon Keys: These are safe to expose in your Lovable app only if you have configured Row Level Security (RLS) properly. (If you haven't, you have a separate, major data vulnerability. See our guide on The Supabase Security Flaw Leaving Your Lovable App Wide Open).
  • Analytics Tracking IDs: Google Analytics tags or PostHog project IDs are inherently public.

Keys That Must Never Leave the Server (Toxic to Expose)

These keys grant administrative access. If a human or a script possesses them, they can perform actions as if they were the owner of the account.

  • OpenAI Secret Keys (sk-proj-...): Grants full access to generate text, images, or code against your billing limit.
  • Stripe Secret Keys (sk_live_...): Grants total control over your Stripe account. An attacker can refund transactions, view all customer data, and create arbitrary charges.
  • SendGrid / Mailgun API Keys: Allows an attacker to send unlimited spam emails from your verified company domain, permanently ruining your email deliverability.
  • AWS Secret Access Keys: Grants control over your cloud infrastructure. Attackers use these to spin up crypto-mining servers on your account.

The Rotation Trap: Why Replacing the Key Achieves Nothing

When a founder discovers an exposed key, the immediate reaction is usually to log into OpenAI or Stripe, delete the compromised key, and generate a new one. This is called rotating the key.

They then take the new key, paste it back into their Bolt or Lovable project, and redeploy the app.

This solves nothing. You have just replaced the compromised key with a fresh one and published it directly back into the browser for the bots to scrape again. You have reset the clock, but you have not fixed the leak.

Before you rotate a key, you must fix the architecture that exposed it in the first place.

The Architectural Fix: Moving Calls Server-Side

To secure your API keys, your front-end application must stop talking to third-party services directly. Instead, you must introduce a middleman: a secure server environment.

When a user clicks "Generate Quote" in your app, the process should follow this path:

  1. The user's browser sends a request to your custom backend (or an Edge Function), asking for a quote.
  2. Your backend—which securely holds the OpenAI API key in a protected environment—makes the request to OpenAI.
  3. OpenAI sends the result back to your backend.
  4. Your backend formats the result and sends it down to the user's browser.

In this model, the browser never sees the API key. The user cannot intercept it, and automated bots cannot scrape it.

Implementing the Fix

If you used an AI builder, you are likely using a modern stack like Next.js, or a Vite app connected to Supabase. You have two main options for moving your logic server-side:

Option A: Edge Functions (Fastest for Supabase Users) If your prototype uses Supabase for authentication and database storage, Supabase Edge Functions are the most direct solution. You write a small piece of TypeScript that lives securely on Supabase's servers. Your Lovable front-end calls the Edge Function, and the Edge Function calls OpenAI. The secret key is stored securely in the Supabase dashboard, never touching the client code.

Option B: Next.js API Routes If Bolt generated a Next.js application for you, the fix involves moving your API calls out of the React components (the front-end) and into the /api directory (the back-end). You then remove the NEXT_PUBLIC_ prefix from your environment variables so they remain strictly on the server.

This transition—from a direct browser integration to a proxied server call—is the line where a vibe-coded prototype becomes a deployable piece of software. It prevents the webhook and payment failures that happen when real money arrives and ensures your company data remains isolated.

Moving from Prototype to Production

AI tools are phenomenal for scoping and validating B2B workflows. They allow non-technical operators to turn a spreadsheet and a process document into functional software in a weekend.

But generating code is not the same as engineering secure software. The defaults chosen by AI agents prioritise immediate visual success over operational security. If you intend to run real business operations through a platform generated by Bolt or Lovable, the output must be audited, stripped of shortcuts, and rewired for production.

Do not deploy a prototype containing raw API keys to your team or your clients. Find the leaks, move the sensitive calls to a secure backend, and only then rotate the keys in your vendor dashboards. If you need a professional engineering team to bridge the gap between your AI prototype and a secure operational tool, our review and hardening starts at £199.

Key Terms

Client Bundle

The final package of JavaScript, HTML, and CSS files sent to a user's browser to render the application.

Edge Function

A small piece of server-side code that runs close to the user, acting as a secure middleman between your front-end and third-party APIs.

Environment Variable

A configuration value used to pass settings, like API keys, into an application without writing them directly into the source code.

Quick Comparison

Architecture Where the Key Lives Security Risk Ideal Use Case
Client-Side Call Browser Bundle (Public) Critical (Keys can be stolen and abused) Stripe tokenisation, Google Analytics
Server-Side Edge Function Secure Backend Environment Low (Browser never sees the key) OpenAI generation, Stripe charges, Email sending

Step by Step

  1. 01 Open your published Bolt or Lovable prototype in Google Chrome.
  2. 02 Right-click anywhere on the page and select 'Inspect' to open Developer Tools.
  3. 03 Navigate to the 'Network' tab and reload the page.
  4. 04 Click the magnifying glass search icon within the Network panel.
  5. 05 Search for key prefixes like 'sk-proj' (OpenAI) or 'sk_live' (Stripe).
  6. 06 If results appear in the JavaScript files, your keys are exposed and must be moved server-side before rotation.

Frequently Asked Questions

Can I just hide my API keys in the Vercel or Netlify dashboard?
No. If your front-end code is written to require those keys directly in the browser, your hosting provider will inject them into the public JavaScript bundle during the build process, exposing them to users.
Why did Bolt.new expose my API keys?
AI coding agents prioritise immediate visual success. Building a secure backend takes extra architectural steps, so the AI takes the shortcut of routing API calls directly from the browser, which requires exposing the keys.
Is the Stripe Publishable key safe to expose?
Yes. Stripe Publishable keys (starting with pk_live or pk_test) are designed to be public and safely tokenise credit card data in the browser. However, Stripe Secret keys (starting with sk_live) must never be exposed.
How do I check if my API keys are exposed?
Open your live app in Google Chrome, right-click and select Inspect, open the Network tab, reload the page, and search for the prefix of your key (e.g., sk-proj for OpenAI).

Bottom line

Do not deploy a vibe-coded prototype to live operations without a security review. Move all sensitive API calls to edge functions or a dedicated backend, rotate the compromised keys, and restrict your public keys by domain. Our review and hardening starts at £199.

How Samvara researches this guide

We write for exhibition organisers and import/export operators in Australia, the UK, Europe, the US and India. Guides favour specific, verifiable operational advice over generic tips — grounded in systems we have shipped, client workflows, and current industry practice. We revisit articles as tooling and regulations change.

Written by

Shreyansh Doshi, Founder of Samvara

Shreyansh Doshi is the founder of Samvara Technologies, a product studio building operator software and SaaS products for exhibition, import/export, travel and fitness businesses in the UK and Australia. He writes about product delivery, operations systems, and where AI does and does not belong in a real workflow.

Keep Reading

Popular in Product Building

Guides readers open next