01CriticalSecurity
Possible exposed OpenAI API key in client-side code
- What this means
- Anything in your frontend JavaScript is public. Bots scrape bundles for keys within minutes of deploy.
- Business impact
- Financial loss (API bills), data theft.
- Evidence
OpenAI API key: sk-pro…x9Q (164 chars) — found in index-4f2a9c.js
- How to fix
- 1Revoke / rotate this key immediately.
- 2Move the call to a server-side route and read the key from a server-only env var.
- 3Never prefix secrets with VITE_ / NEXT_PUBLIC_.
- Copy-paste AI fix prompt
I am building an app using an AI builder (Lovable / Bolt / Cursor / Replit / v0). My app URL is: https://demo-app.example Issue found: Possible exposed OpenAI API key in client-side code Evidence: OpenAI API key: sk-pro…x9Q (164 chars) — found in index-4f2a9c.js Risk: Financial loss (API bills), data theft. Please fix this issue without breaking existing functionality. Use secure best practices, avoid exposing secrets in the frontend, and explain exactly what you changed. Suggested approach: 1. Revoke / rotate this key immediately. 2. Move the call to a server-side route and read the key from a server-only env var. 3. Never prefix secrets with VITE_ / NEXT_PUBLIC_.