Watch: Hide my AI API key so users can't steal it | Vovy
Watch Vovy do it on a Mac: "My OpenAI key is in my frontend code. Move it somewhere safe". Move your AI API key out of browser code into a server function, rotate the exposed key, and keep your app's AI feature working.
"My OpenAI key is in my frontend code. Move it somewhere safe"
Move your AI API key out of browser code into a server function, rotate the exposed key, and keep your app's AI feature working.
What happens in the video
- Prove the key is exposed: Vovy opens your live site, checks the browser's network and source files, and shows you the key sitting there for anyone to copy.
- Create a server function: Vovy asks Claude Code to make a Supabase Edge Function that takes the user's message, calls the AI with the secret key, and returns the reply.
- Require a signed-in user: Claude Code makes the function check the user's session, so strangers cannot use your endpoint as a free AI proxy.
- Point the frontend at it: Claude Code replaces direct AI calls with calls to your function and deletes the key from frontend code and .env files with public prefixes.
- Rotate the old key: The old key was public, so Vovy creates a new one, stores it as a Supabase secret, and deletes the old one. Deleting a key is irreversible, so it asks.
Read the step-by-step guideLoading...