How to correctly use Service Role Client in Edge Functions with new JWT Signing Keys?
Hey Supabase community!
I'm migrating my project to the new JWT Signing Keys and have disabled the legacy
Previously, we used the legacy keys:
We could invoke the function with the
Now, with the new API Keys enabled, we've updated our configuration:
We configured it to be invocable without JWT as a backend function triggered by a cron job:
We invoke it directly:
The Problem:
The function is invoked, but when
A test function confirmed that
My Question:
After disabling legacy API keys, what is the correct way to configure and initialize the service role client (
Thanks!
I'm migrating my project to the new JWT Signing Keys and have disabled the legacy
anon and service_role keys as recommended. However, I'm running into an issue authenticating my Edge Functions to use the service role client.- The Old (Working) Method:
Previously, we used the legacy keys:
We could invoke the function with the
anon-key and it worked perfectly.- The New (Not Working) Method:
Now, with the new API Keys enabled, we've updated our configuration:
We configured it to be invocable without JWT as a backend function triggered by a cron job:
We invoke it directly:
The Problem:
The function is invoked, but when
getServiceRoleClient() is called inside it, we get error, because the new SUPABASE_SECRET_KEY environment variable doesn't seem to be populated in the Edge Function runtime:A test function confirmed that
SUPABASE_SERVICE_ROLE_KEY is present in the runtime (though being disabled and invalid), but SUPABASE_SECRET_KEY is missing.My Question:
After disabling legacy API keys, what is the correct way to configure and initialize the service role client (
createClient) inside an Edge Function? How do we access the new secret key from within the Deno runtime?Thanks!