SupabaseS
Supabase11mo ago
Mario

Database error with local edge functions

Hi there,

I'm kind of new to all this, so apologies if there are things that are super obvious to a proper SWE.

I have a project that uses edge functions to store information in my supabase database and storage. That works as intended in my production setting. However, when I try to do this locally, it fails.

What I've done and tested:
  • I adjusted the .env variables accordingly and checked with logging that this is correctly setup
  • when using a curl request, I actually can connect to my local database as intended
  • the local database has the exact same schema as the remote database
  • I run npm run dev & supabase functions serve --env-file ./supabase/functions/.env --no-verify-jwt --debug | cat
  • When I run my edge function, that is supposed to insert something into a database, I get this error:
    [Error] Database error: {
    message: "TypeError: error sending request for url (http://localhost:54321/rest/v1/image_generations?select=*)",
    details: "TypeError: error sending request for url (http://localhost:54321/rest/v1/image_generations?select=*)\n" +
    " at async mainFetch (ext:deno_fetch/26_fetch.js:170:12)\n" +
    " at async fetch (ext:deno_fetch/26_fetch.js:391:7)\n" +
    " at async Server.<anonymous> (file:///Users/marioottmann/Coding/magicdoodles/supabase/functions/store-generation-metadata/index.ts:36:29)\n" +
    " at async #respond (https://deno.land/std@0.208.0/http/server.ts:224:18)",
    hint: "",
    code: ""
    }
I test via both frontend and: curl -i --location --request POST 'http://127.0.0.1:54321/functions/v1/store-generation-metadata' --header 'Content-Type: application/json' --data-raw '{"userId": "00000000-0000-0000-0000-000000000000","preprompt": "test preprompt","prompt": "test prompt","imageUrl": "https://test-image-url.com/image.png"}' | cat
Was this page helpful?