OpenAI API key exposed in public code
We found what looks like an OpenAI API key in JavaScript that anyone can download from your site. Anyone can copy this key and run up charges on your OpenAI account. Treat it as leaked: make a new key and turn off the old one, even after you fix the code.
- sk-proj-…-key (35 chars) in example.app/assets/app-3f9a.js
In my AI app builder (Lovable, Bolt, Cursor, Replit, v0 or similar): My OpenAI API key is exposed in my front-end JavaScript. 1. Move every OpenAI call to a server-side function or API route. Read the key from a server-only environment variable. 2. Remove the key from all client-side files and from any env variable that starts with NEXT_PUBLIC_, VITE_ or REACT_APP_ (those get shipped to the browser). 3. Make sure the browser calls my own server/API route, and only the server talks to the outside service. 4. Show me every file you changed. (I will make a new key in the provider's dashboard and turn off the old one myself.)
