Guide · API keys
Is your API key exposed in your website's code?
If your site calls OpenAI, Stripe or another paid service straight from the browser, the secret key is in the page code, and anyone can copy it. Here is how to find out in two minutes and what to do about it.
Free instant check, no sign-up. It reads your page code the way any visitor could.
How a secret key ends up in the page code
Everything the browser runs is sent to every visitor. If the page itself calls a paid service, it has to send the key along, so the key is in the code. AI tools do this a lot because it is the shortest way to make a feature work.
A common trap is the name of the setting. In Vite projects every variable that starts with VITE_ is copied into the page code; in Next.js the same goes for NEXT_PUBLIC_. Putting a secret key in VITE_OPENAI_API_KEY publishes it, even though it sits in a .env file.
Which keys are safe to show and which are not
| Key | In the page code |
|---|---|
OpenAI sk-…, sk-proj-… | Secret. Anyone can spend your credits. |
Anthropic sk-ant-… | Secret. |
Stripe sk_live_…, rk_live_… | Secret. Refunds, customer data, payouts. |
Supabase service_role | Secret. Skips every database rule. |
AWS AKIA…, GitHub ghp_…, Slack xox… | Secret. |
Stripe pk_live_… | Public by design. |
Supabase anon or sb_publishable_… | Public by design, if Row Level Security is set up. |
Firebase web config (apiKey: "AIza…") | Public by design, if security rules are set up. |
Google Maps AIza… | Fine if restricted to your domain in Google Cloud. |
Find it yourself in two minutes
- Open your live site in Chrome, Edge or Firefox and press F12.
- Open the Sources tab (Debugger in Firefox) and search all files: Ctrl+Shift+F, or Cmd+Option+F on a Mac.
- Search one by one for
sk-,sk_live,service_role,AKIA,ghp_andsecret. - Also open the Network tab, use the app, and look at requests going straight to
api.openai.com,api.anthropic.comorapi.stripe.com. If they leave the browser, the key is in it.
Check the live site, not only your project files: what matters is what the server actually sends to visitors.
If you found one
- Revoke it first. Create a new key in the provider's dashboard and delete the old one. Removing it from the code is not enough: it stays in old builds, caches and your git history, and bots copy keys within minutes of a site going live.
- Move the call to the server. The page calls your own server (an API route, a Supabase Edge Function, a serverless function), and only the server holds the key and calls the paid service.
- Make the server check who is asking. Otherwise strangers simply call your server instead of the provider, and the bill is still yours. Require a login and limit how often one user can call it.
- Set a spending limit in the provider's dashboard, so a leak costs a little, not everything.
A prompt for your AI tool
Find every place where the browser code uses a secret API key (OpenAI, Anthropic, Stripe secret key, Supabase service_role or any other). Move each of those calls to a server-side function, read the key there from a server-only environment variable (never one that starts with VITE_ or NEXT_PUBLIC_), require a signed-in user before calling the provider, and make the page call that function instead. Then list the keys I need to rotate.
What the ShipProof check finds
The free check loads your live site and the scripts it serves, then looks for the secret key formats in the table above: OpenAI, Anthropic, Stripe, the Supabase service_role key, AWS, GitHub and Slack tokens, and private keys. It reports where each one is, shows only the first and last characters, and gives a fix prompt. It also tells you if your original source code can be downloaded through source maps, which often shows more than the built page.
The full check, after you prove the site is yours, also looks for an exposed .env file and .git folder.
Check your site for leaked keys
A grade and the problems in plain language in a few seconds.