Skip to content

Lovable backendLovable: the edge function can’t read my API key

Payments, emails or AI calls fail, and the edge function log says a key is missing or invalid. In Lovable, those keys live in Secrets, and a few settings decide whether the function can read them. Here’s each one in Lovable’s own words, and the fix, or hand it over at a fixed price.

Short answer

Edge functions read keys from Secrets by exact name, such as STRIPE_SECRET_KEY. Check the secret exists with the name the function reads, add any secret you skipped when Lovable asked, and don’t put server keys in VITE_ variables, which go to the browser. If two Lovable projects share one Supabase project, they overwrite each other’s secrets.

Why the key is missing, and the fix

  1. 01

    The secret was skipped or never added

    “Anything that depends on the secret won't work until you add it.” Lovable, Secrets

    When Lovable asked for the key, the prompt may have been skipped. Add it under More, Settings, Secrets, or ask Lovable in the chat to request it again. With your own Supabase project connected, secrets are managed in the Supabase dashboard instead. Names starting with SUPABASE_ or LOVABLE_ already exist, so don’t add those yourself.

  2. 02

    The project was remixed

    “Manually added secrets are not copied over, so re-enter them in the new project.” Lovable, Secrets

    A remix gets fresh copies of the keys Lovable generates, but not the ones you added. Add those again in the new project.

  3. 03

    The name doesn’t match

    “The name is usually the exact environment variable your Edge Function will read.” Lovable, Secrets

    The function reads one exact name. A secret saved as STRIPE_KEY won’t be found by code reading STRIPE_SECRET_KEY. Check the names in the Secrets list against the function code.

  4. 04

    The key was put in a VITE_ variable

    “Anything prefixed with VITE_ is a build-time, browser-exposed value and must live in your project's .env file instead, not in Secrets.” Lovable, Secrets

    VITE_ variables are build-time values built into the page the browser downloads, so anyone can see them; they belong in .env, not in Secrets. Edge functions read server keys from Secrets. If a secret key was ever in a VITE_ variable, replace it at the service that issued it.

  5. 05

    Two projects share one Supabase project

    “Lovable projects that share one Supabase project overwrite each other's secrets, including LOVABLE_API_KEY, so any feature that uses that key stops working.” Lovable, Supabase integration

    With your own Supabase project connected, Lovable projects that use the same one overwrite each other’s secrets. Give each its own Supabase project. If you share one on purpose, remember each project’s saves overwrite the other’s, including LOVABLE_API_KEY.

Checked against the vendor’s docs on : Lovable docs: Secrets; Lovable docs: Supabase integration (secrets).

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

Related: Supabase service_role key exposed · Is Lovable safe for a real app? · Hire a Lovable developer

Questions

More on this error

Can I see the value of a saved secret?

No. Lovable says secrets are write-only: once saved they can be replaced or deleted but never viewed. If you’ve lost a key, create a new one at the service that issued it.

I pasted my API key into the chat. What happens?

Lovable says that when you send a message with an API key, it saves the key as a project secret, and it may offer to set up a connector for that tool. Lovable also asks for keys through a secure input, so use that where you can. If the key was ever pasted somewhere public, or into a VITE_ variable, replace it at the service that issued it.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; we reply by email, usually within one business day.