Cant access SUPABASE_URL from my Edge function

I am trying to access my Supabase environment variables from my edge function like this
const supabase = await createClient(
Deno.env.get(SUPABASE_URL),
Deno.env.get(SUPABASE_SERVICE_ROLE_KEY),
{
auth: {
autoRefreshToken: false,
persistSession: false,
},
}
);
const supabase = await createClient(
Deno.env.get(SUPABASE_URL),
Deno.env.get(SUPABASE_SERVICE_ROLE_KEY),
{
auth: {
autoRefreshToken: false,
persistSession: false,
},
}
);
But getting error like: ReferenceError: SUPABASE_URL is not defined what am I missing?
3 Replies
Staffan Solin
Staffan SolinOP2y ago
According to this article I should be able to access these env variables by default https://supabase.com/docs/guides/functions/secrets
Managing Environment Variables | Supabase Docs
Managing secrets and environment variables.
Olyno
Olyno2y ago
If you scroll down a little bit on the documentation, you have the usage:
console.log(Deno.env.get('MY_NAME'))
console.log(Deno.env.get('MY_NAME'))
You can also have the look from Deno directly: https://examples.deno.land/environment-variables
Environment Variables - Deno by Example
Environment variables can be used to configure the behavior of a program, or pass data from one program to another. -- Deno by example is a collection of annotated examples for how to use Deno, and the various features it provides.
Olyno
Olyno2y ago
All default env names are also available on the same page

Did you find this page helpful?