I'm trying to develop a local supabase edge function. I have followed the documentation and correctly installed and locally deployed the function.
I have a simple edge function that, when it receive a request, it fetches some data from the database:
import { createClient } from 'https://esm.sh/@supabase/[email protected]'
Deno.serve(async (req) => {
try {
const supabase = createClient(
Deno.env.get('SUPABASE_URL') ?? '',
Deno.env.get('SUPABASE_ANON_KEY') ?? '',
{ global: { headers: { Authorization: req.headers.get('Authorization')! } } }
)
// Fetch all websites from the 'websites' table
const { data: websites, error } = await supabase
.from('websites')
.select('url')
.limit(1)
if (error) {
console.log(error)
throw error
}
I use supabase function serve to test locally but, everytime I launch http://127.0.0.1:54321/functions/v1/<function-name> to test it I have the error
{"error":"relation \"public.<table_name>\" does not exist"}
I have also tried to change the SUPABASE_ANON_KEY with the SUPABASE_SERVICE_ROLE_KEY but same issue
The table public.<table_name> exist on my cloud instance of Supabase
I have also tried to disable RLS but still the same issue.
I have also tried to follow this simple example but it fails...
Running the SQL questy directly on Supabase cloud works SELECT <column_name> FROM public.<table_name>
I think there's some issue with the local edge function