Home / patterns

Third-party secret keys (OpenAI, Stripe, Resend) in client JS

Quick answer: Billed third-party secrets in browser bundles let anyone spend on your account. Publishable keys belong in the client; secret and service_role keys do not.

Last updated November 14, 2026

Steps

  1. Open your own production site → DevTools → Sources (or Network → JS bundles).
  2. Search for sk-, sk_live, sk_test, sk-proj-, re_, Bearer tokens, and service_role.
  3. If you find a secret, rotate it at the vendor immediately and treat it as leaked.
  4. Move calls to a server route or edge function; keep secrets in server-only env vars (never NEXT_PUBLIC_ / VITE_ prefixes).
  5. Confirm Supabase secret/service_role keys stay server-side; only the publishable key belongs in the browser — see https://supabase.com/docs/guides/getting-started/api-keys

Why it matters

Guides on securing Lovable/Bolt apps warn about keys in the client and misconfigured RLS: https://lorikeetsecurity.com/blog/securing-lovable-bolt-apps-production

Security Scanner, a scanning vendor, reported in an April 24, 2026 post about its own read-only scan of 1,003 vibe-coded apps that its ai-js module flagged 38 apps with hardcoded API keys in their JS bundles, including 17 of 251 Bolt.host apps (6.8%) and 18 of 67 AI-generated Vercel apps (26.9%). These are the vendor's self-reported figures: https://securityscanner.dev/blog/beyond-supabase-rls-five-other-crits

Self-check your own app only. If you find a leaked key, rotate it first. If you want help moving the call to a server route, StorenTech can send you a fixed quote.

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.