© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3mo ago•
10 replies
Colin Emonds

Cannot access new service role API key from Edge Function runtime

edge functions
Hi,

so, apparently Supabase has deprecated their bad authentication scheme in favor of an even more broken one, while addressing none of the issues with the old one, and not even bumping the major version number to announce the breaking change. Cool - that's the quality I'm used to at this point.

One particular pain point with the newly introduced API keys, though, is that I have a bunch of Edge Functions which I only want to be accessible to users that know the service role key. The reasoning is that these Edge Functions perform system maintenance or data import tasks that regular users should not be able to control, and they only get called via an admin
curl
curl
ing them.

My previous solution essentially was this:

Deno.serve(async (req) => {
  if (
    req.headers.get('authorization') !==
    `Bearer ${Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')}`
  ) {
    return new Response('Unauthorized', { status: 401 });
  }
Deno.serve(async (req) => {
  if (
    req.headers.get('authorization') !==
    `Bearer ${Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')}`
  ) {
    return new Response('Unauthorized', { status: 401 });
  }


This worked perfectly fine for me. But with the new system, I am not sure what I'm supposed to do here.

1. I'm not supposed to use the JWT-based service role anymore. In local development, this already doesn't work, as the CLI tools no longer show it. (I could probably hack around that, but that wouldn't be future-proof.)
2. I can't use the new API key, as I am not sure how to access it. It doesn't appear to be documented anywhere how that key could be obtained, and in any case, it's not in
Deno.env
Deno.env
.

So I guess I create a
vault
vault
secret
system_administration_api_key
system_administration_api_key
and then use that for my edge functions?

I'm mostly just venting here, I suppose.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Using service role in Edge Function
SupabaseSSupabase / help-and-questions
7mo ago
Edge Function cannot insert into table with RLS even using Service Role Key
SupabaseSSupabase / help-and-questions
5mo ago
Ensure edge function is invoked only with valid service-role key
SupabaseSSupabase / help-and-questions
4y ago
How to change Service_Role API key
SupabaseSSupabase / help-and-questions
5d ago