Search Psychevus

12 results available.
↑ ↓ to navigate ↵ to open · esc to close

Vite · Next.js · Lovable · Bolt · Expo

Are your API keys exposed in your JavaScript bundle?

Which keys are safe in the browser (Supabase anon, Stripe publishable, Firebase config) and which must never ship (service_role, Stripe secret, OpenAI, Anthropic, Resend). How to check a live site and fix it.

Short answerAnything in an environment variable named VITE_*, NEXT_PUBLIC_*, REACT_APP_* or EXPO_PUBLIC_* is compiled into the JavaScript every visitor downloads. Publishable keys are designed for that (Supabase anon or publishable keys, Stripe pk_, Firebase web config). Secret keys are not: Supabase service_role or sb_secret_, Stripe sk_live_, and OpenAI, Anthropic, Resend or GitHub tokens must live only in server code. If one shipped, rotate it, then move the call behind a server function.

Safe in the browser vs. never in the browser

  • Safe by design: Supabase anon/publishable key (protected by RLS), Stripe publishable key pk_live_ / pk_test_, Firebase web config (protected by security rules), public analytics IDs.
  • Never: Supabase service_role / sb_secret_ keys, Stripe sk_live_ / rk_live_, OpenAI sk-proj-…, Anthropic sk-ant-…, Resend re_…, SendGrid SG.…, GitHub tokens, AWS secret keys, any private key.

How keys end up in the bundle

An AI builder needs a value in the frontend, so it adds a VITE_ or NEXT_PUBLIC_ variable. The app works. The key is now public. The same happens when a fetch to OpenAI is written in a React component instead of a server function.

Check a build locally
npm run build
grep -rEo "sk_live_[0-9a-zA-Z]{10}|sk-proj-[A-Za-z0-9_-]{10}|sk-ant-[a-z0-9]+-[A-Za-z0-9_-]{10}|sb_secret_[A-Za-z0-9_-]{10}|service_role" dist/ .next/static/ 2>/dev/null

Fix

  • Rotate the exposed key at the provider first: removing it from code doesn't un-publish old deployments.
  • Move the call into a server route or Edge Function that reads the key from a non-public environment variable.
  • Rate-limit that route per user, especially if it calls a paid AI API.

Check it yourself

Run the free exposure check on your live URL. It reads your page and the scripts it loads, exactly as a browser does, and reports known secret formats redacted.

Check what your app exposes (free, 30 seconds)

Questions

Can I hide a key with obfuscation or base64?

No. Anything the browser can use, a person can read. The only fix is to keep the key on a server.

Is my Supabase anon key a problem?

Not by itself. It's public by design; check your Row Level Security policies instead.

Updated 18 November 2026 · by

Reading about a flaw is the easy part. A Launch Check finds every one of these in your app, with evidence and a fix prompt for each, in two business days.

Get a fixed quote

Related

YOUR VISIT, YOUR CHOICE

Privacy, by intention.

You decide what stays on your device. You can change your choice at any time.

Essential

Saves your privacy choice. Administrator sign-in uses a secure session cookie.

Always on
Full privacy notice ↗