Invoking a local edge function from local SQL editor

Hello, I have a question about local supabase development. I have spun up a local Supabase instance with supabase start and created an edge function that I've spun up locally as well with supabase functions serve my-function.

I'm trying to invoke the function through the Postgres HTTP extension, using the authorization header provided in the curl example, at the end of the generated Edge Function. But I'm getting back "Failed to connect to localhost port 54321: Connection refused".

select status
  from
    http((
      'POST',
      'http://localhost:54321/functions/v1/',
      array[
        http_header('Authorization','Bearer MY_KEY')
      ],
      '',
      'application/json'
    )::http_request)


(By the way this method works fine when I deploy my function and call it the same way on the hosted Supabase SQL editor).

So my question is: should it even be possible to invoke a locally served edge function through a locally running Supabase SQL editor?

As a secondary question - is there any way to reference the SERVICE_KEY in a SQL Editor, without actually writing the key into the SQL statement? Similar to how the SERVICE_KEY is automatically provided through env variables when working in Edge Functions.

Thanks!
Was this page helpful?