SupabaseS
Supabase4y ago
Eyk

net.http_post permission denied in trigger

I'm trying to use pg_net's net.http_post within an AFTER INSERT trigger on the auth.audit_log_entries table, but I keep getting Internal Server Error with the error message "ERROR: permission denied for schema net (SQLSTATE 42501)".

I tried possible fixes like https://github.com/supabase/supabase/issues/4883#issuecomment-1017955034, but nothing works for me.

Does anyone have an idea?

code:
CREATE EXTENSION IF NOT EXISTS pg_net;

CREATE OR REPLACE FUNCTION stream_auth_logs()
RETURNS trigger AS $$
BEGIN
  select net.http_post(
        url:='...',
        body:='{"hello": "world"}'::jsonb
  );

  RETURN NEW;
END;
$$ LANGUAGE plpgsql;

DROP TRIGGER stream_auth_logs_trigger on auth.audit_log_entries;

CREATE TRIGGER stream_auth_logs_trigger
AFTER INSERT ON auth.audit_log_entries
FOR EACH ROW
EXECUTE PROCEDURE stream_auth_logs();
GitHub
Bug report Describe the bug When trying to access data from some API endpoints, like this: /rest/v1/leads?select=* I get this error: { "message": "permission denied for t...
Was this page helpful?