0

Let's say I have an edge function called "hello-world".

Question 1

How can I rewrite the SQL example from the supabase documentation to trigger the edge function "hello-world" in sql (e.g. without the supabase GUI)?

create trigger "my_webhook" after insert
on "public"."my_table" for each row
execute function "supabase_functions"."http_request"(
  'http://localhost:3000',
  'POST',
  '{"Content-Type":"application/json"}',
  '{}',
  '1000'
);

Question 2

If the edge function must read another rls secured database table, do I have to call the edge function with a postgres role? How would I implement that with the SQL webhook?

1 Answer 1

0

Simply add the the edge function url as https parameter and an Authorization header in the first paranthese:

create or replace trigger "send-push-hook" after insert
on authenticated_access.notifications_by_user for each row
execute function supabase_functions.http_request(
  'https://<project-url>.supabase.co/functions/v1/<function-name>',
  'POST',
  '{
    "Content-Type":"application/json",
    "Authorization": "Bearer <your authorization for example service role key>"
    }',
  '{}',
  '1000'
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.