View all guides
5 min read

Debugging Supabase Edge Functions

Edge Functions are like a backend for your app which enable you to do things your frontend app can’t do securely or directly.

Debugging Supabase Edge Functions
GJ
Gregory John
Buildcamp Founder

If you need to send an email through Loops.so, or call OpenAI with your secret API key, you don’t want to expose those secrets in the browser — you’d use an Edge Function instead. Same with Stripe — if someone buys something, you can use an Edge Function to handle the payment confirmation and update your database.

Image

Basically, Edge Functions let you run code safely on the server for anything that requires protection or custom logic.


Debugging:

Let’s use the scenario of creating an edge function that sends a welcome email (via loops.so) when a user signs up to the app. During testing, the email does not arrive.

✅ Step 1: Make sure the edge function exists

Go to Supabase Dashboard → Edge Functions → Functions

Confirm you see your function (e.g., send-welcome-email)

If it’s not there, go back to Lovable and prompt “My welcome email edge function does not exist on Supabase”

🔑 Step 2: Check the Loops.so secret key

Go to Supabase Dashboard → Edge Functions → Secrets Look for something like LOOPS_API_KEY

If it’s not there, go back to Lovable and prompt “My Loops secret does not exist on Supabase. Lovable will then prompt you to paste it in via modal so it can deploy the secret key.

📡 Step 3: Check Invocations

Go to Supabase Dashboard → Edge Functions → Functions → “function name” → Invocations

Look for any recent requests with ‘400’ or ‘500’

Example 👇 Image

  • ❌ 400 Bad Request → usually a problem with what Lovable sent
  • ❌ 500 Server Error → something went wrong inside the function

Click on the error and then in the detail pane on the right side, copy the error code and paste it back into Lovable

Image

📝 Step 4: Check the Logs

An identical process to invocations, this time using the Logs tab. Click the Logs tab next to Invocations

Look for anything in red.

Example 👇

Image

Click on the error and then in the detail pane on the right side, use the clipboard icon to copy the message and paste it back into Lovable.

Continue this process until your edge function works.

Tip: If you don’t see any invocations or logs, then it’s a problem on the Lovable side.

Share this guide: