VibeTester

Pre-launch guide

How to Find Exposed API Keys in Frontend Apps

A frontend bundle is public by design. Obscuring a key in minified JavaScript does not protect it. This guide explains how to identify a real exposure, contain it quickly, and avoid shipping privileged credentials in browser code again.

Run a free browser QA scan

Use VibeTester for a fast independent check of buttons, browser errors, mobile overflow, and public secrets.

Scan my app

1. Know what counts as an exposure

If a credential reaches a browser, assume a motivated visitor can retrieve it. Some providers intentionally expose public identifiers, but private provider keys, unrestricted tokens, service-role credentials, and cloud access keys should never be in the frontend.

2. Check the deployed application

Review inline scripts, downloaded JavaScript bundles, configuration endpoints, and source maps if they are public. Search for provider prefixes, environment variable names, and terms such as secret, token, key, service role, or private. Scan the deployed domain instead of relying only on repository search.

3. Look for accidental public files

Deployment mistakes can expose files that were never meant to be served. Check common sensitive paths such as .env and .git/config, and verify hosting configuration does not publish build artifacts, backups, or source files unintentionally.

4. Rotate before you refactor

If you find a real secret, revoke or rotate it immediately. Removing it from a bundle stops future exposure, but it does not invalidate a value that may already have been copied. Review provider logs, spending, and access history where available.

5. Move privileged operations server-side

The safe pattern is browser to your server-side endpoint to provider. Keep provider secrets in server-side environment variables, authenticate and authorize the caller, validate input, and rate-limit expensive operations. Do not solve the problem by merely renaming or encoding the client-side variable.

6. Prevent the next incident

Use separate public and server-only configuration names, scan builds before deployment, restrict keys at the provider when possible, and teach contributors that a frontend environment variable is public. Restrictions reduce blast radius but do not turn a secret into a public value.

Launch checklist

  1. 1.Scan the live domain's inline scripts and JavaScript bundles.
  2. 2.Check common accidental files such as .env and .git/config.
  3. 3.Classify every discovered key as public identifier or privileged secret.
  4. 4.Rotate any exposed privileged credential immediately.
  5. 5.Move protected provider calls to server-side code.
  6. 6.Add deployment-time secret scanning and provider restrictions.

Frequently asked questions

Can I hide an API key by putting it in a frontend environment variable?

No. Any value embedded into client-side JavaScript can be recovered by a visitor. Frontend environment variables are configuration, not secret storage.

What should I do if I find an exposed API key?

Rotate or revoke it immediately, review provider activity, remove it from browser code, and move the privileged request to a server-side environment.

Are publishable keys safe to expose?

Some providers issue public identifiers for browser use. Confirm the key type in the provider documentation and ensure it cannot perform privileged actions or access private data.