Skip to content

Having trouble accessing database from edge funtion. #32437

Discussion options

You must be logged in to vote

This is the issue, you cannot set these manually as the edge runtime is inside a docker container. You need to use the preset env variables that Supabase resolves automatically by itself.

import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import { createClient } from "npm:@supabase/supabase-js@2";

export async function getToken() {
  //Create supabase client
  const supabaseUrl = Deno.env.get("SUPABASE_URL");
  const serviceKey = Deno.env.get("SUPABASE_SERVICE_ROLE_KEY");
  const supabase = createClient(supabaseUrl, serviceKey);

You can read more about the default secrets here https://supabase.com/docs/guides/functions/secrets#default-secrets

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@GoGoGadgetGitHub
Comment options

@silentworks
Comment options

Answer selected by GoGoGadgetGitHub
@GoGoGadgetGitHub
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants