What is wrong
A database admin key is bundled into the public JavaScript. Anyone who opens DevTools can read, change or delete every row.
Impact: Full database takeover by any visitor. Customer data could be dumped in minutes.
Evidence (fixture)
src/lib/db.ts:4–7 · commit a3f9c21
const db = createClient(URL, "eyJhbGciOi…service_role…") // fixture
Expected
Only the publishable key reaches the browser.Observed
service_role key found in built bundle assets/index-8f2a.js (fixture).Recommended fix
Move privileged calls to a server function, rotate the key, and use the publishable key client-side.
Repair prompt for your AI builder
In src/lib/db.ts the service-role key is used in browser code. Move every privileged query into a server-side function, replace the client with the publishable key, and remind me to rotate the leaked key.
Paste it into Lovable, Claude Code, Cursor or Codex.