# Invoking Edge Function Bug

**URL:** <https://community.weweb.io/t/invoking-edge-function-bug/19019>\
**Category:** Ask us anything\
**Tags:** supabase\
**Created:** [June 30, 2025, 4:14pm UTC](https://community.weweb.io/t/invoking-edge-function-bug/19019 "2025-06-30T16:14:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom12345](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@tom12345](https://community.weweb.io/u/tom12345)\
**Post date:** [June 30, 2025, 4:14pm UTC](https://community.weweb.io/t/invoking-edge-function-bug/19019/1 "2025-06-30T16:14:59Z")

</div>

Hi everyone,

I’m trying to send a JSON body using the Supabase **“Invoke an Edge function”** action, but it’s not working as expected.

My Edge Function requires a simple JSON body like `{ "apiKey": "some-value" }` . However, when I use the “Invoke an Edge function” action with the `POST` method, my function logs show that it receives a completely empty body.

I’ve already confirmed that the function itself is correct, as it works perfectly when I test it directly from the Supabase dashboard or other API tools. The issue seems to be specific to how the WeWeb action sends the body.

I’ve tried configuring the “Body” field with both `createObject()` and a raw JavaScript object formula, but neither sends the data.

What is the correct way to configure the **Body** for this action to send a JSON object? Has anyone else run into this?

BTW the REST API works perfectly running this. So it seems that the invoke edge function workflow in weweb has a bug. Any updates

I have seen lots of posts on this exact topic by community but no solution from @DanielL

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![tom12345](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@tom12345](https://community.weweb.io/u/tom12345)\
**Post date:** [June 30, 2025, 4:28pm UTC](https://community.weweb.io/t/invoking-edge-function-bug/19019/2 "2025-06-30T16:28:55Z")

</div>

![Screenshot 2025-06-30 182807](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/b/bf1815821144a1572417ab26750e5fbfa38c5ec1.png)

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [June 30, 2025, 8:14pm UTC](https://community.weweb.io/t/invoking-edge-function-bug/19019/3 "2025-06-30T20:14:21Z")

</div>

Have you CORS headers set up properly?

---

<div class="post-metadata">

**Author:** ![tom12345](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@tom12345](https://community.weweb.io/u/tom12345)\
**Post date:** [June 30, 2025, 8:16pm UTC](https://community.weweb.io/t/invoking-edge-function-bug/19019/4 "2025-06-30T20:16:54Z")

</div>

Yeah I have. I was having CORS issues earlier but fixed them

This is seperate.

---

<div class="post-metadata">

**Author:** ![GeovanyFerreira](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/geovanyferreira/32/13093_2.png) [@GeovanyFerreira](https://community.weweb.io/u/GeovanyFerreira)\
**Post date:** [July 1, 2025, 1:12am UTC](https://community.weweb.io/t/invoking-edge-function-bug/19019/5 "2025-07-01T01:12:01Z")

</div>

Hello @tom12345, I noticed that you are sending some unnecessary headers. When you call the edge function through the plugin, Authorization is already sent by default.  
If you need the base token, use `req.headers.get('Authorization')` to get the value.  
I will leave a simple example below using CORS and also getting the token to query the table.

```auto
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import { createClient } from 'jsr:@supabase/supabase-js@2';

const corsHeaders = {
  'Access-Control-Allow-Origin': '*',
  'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type'
};
Deno.serve(async (req)=>{
  if (req.method === 'OPTIONS') {
    return new Response('ok', {
      headers: corsHeaders
    });
  }
  try {
    const supabase = createClient(Deno.env.get('SUPABASE_URL') ?? '', Deno.env.get('SUPABASE_ANON_KEY') ?? '', {
      global: {
        headers: {
          Authorization: req.headers.get('Authorization')
        }
      }
    });
    // TODO: Change the table_name to your table
    const { data, error } = await supabase.from('table').select('*');
    if (error) {
      throw error;
    }
    return new Response(JSON.stringify(data), {
      headers: {
        ...corsHeaders,
        'Content-Type': 'application/json'
      },
      status: 200
    });
  } catch (error) {
    return new Response(JSON.stringify({
      error: error.message
    }), {
      headers: {
        ...corsHeaders,
        'Content-Type': 'application/json'
      },
      status: 400
    });
  }
});

```
