Supabase allows you to set environment variables for your serverless functions. What happens if you try to access an environment variable that is not set?
Think about how environment variables behave in Node.js when not set.
If an environment variable is not set, accessing it returns undefined (or null in some contexts). Supabase serverless functions behave similarly, so no error is thrown automatically.
You want to use a third-party API key in your Supabase project. Which method ensures the key is kept secret and not exposed to users?
Consider where client-side code can be seen by users.
Environment variables in serverless functions keep secrets safe because they are not exposed to the client. Hardcoding or storing keys in public places risks exposure.
Given you have set an environment variable named MY_SECRET in your Supabase project, how do you access it inside an Edge Function?
export default async function handler(req) { // Access the secret here const secret = Deno.env.get('MY_SECRET'); return new Response(secret); }
Supabase Edge Functions run on Deno runtime, not Node.js.
Supabase Edge Functions use Deno, so environment variables are accessed with Deno.env.get(). process.env is Node.js specific and will not work.
You have development, staging, and production environments. How do you manage environment variables securely and efficiently across these stages in Supabase?
Think about isolation and risk of leaking secrets between stages.
Separate projects per stage isolate environment variables and resources, reducing risk of accidental leaks or interference. Sharing variables or projects risks mixing secrets.
You need to update a secret API key stored in Supabase environment variables used by Edge Functions. How do you rotate the secret safely without causing downtime or errors?
Consider how to avoid breaking running functions during secret updates.
Gradual rollout with new functions using the new secret while old ones still run avoids downtime. Direct replacement risks breaking running functions that rely on the old secret.