Error: Failed to send request to the edge function

Hi, i’m trying to combine weweb, supabase and open ai through an edge function, created in supabase. I’ve gotten the edge function too run using the CLI and now I’m trying to create an workflow using “invoke supabase edge function” I’ve added the correct name and it is POST and two headers, one content-type and one authorization, and finally one an Image hardcoded in the body, that should be analyzed by the AI.

When triggering the action i get the error message: “Failed to send request to the edge function” and cause.name “FunctionFetchError”

Any idea why this error is happening when running it in weweb vs. CLI ?

Have you tried to run this with something like Postman.com to verify that the Edge Function works properly? It can work in the CLI, but might not be accessible from the rest of the internet :slight_smile: If I was you, I’d check this first of all.

1 Like

Sorry for the late replay back(been sick) but I did get it to work in Postman using POST and the correct URL, added bearer token and the service tole key (from supabase) and added image URL in the body and content-type. It worked well. so maybe somewhere the issue is how I implement it in weweb then

I’d suggest you check the network tab for a more detailed error, and if that doesn’t help, you could share it here

It says “405 Method Not Allowed” in the network tab in the browser and just all the other details like URL i sent and auth stuff

I’m guessing there is something CORS related, not sure what that is yet

Yes, you need to send CORS headers when the browser makes a preflight OPTIONS request, for this to work with a browser. I had this issue.