CORS enabled Edge function example in the Supabase docs throwing error when invoked
Hey everyone, since a couple of days we were getting a CORS error in an application that we developed. Worked like a charm before.
I decided to spin up a new Supabase project following the official docs and see if this problem persists. Unfortunately it does.
Steps to reproduce the error:
1. create an empty app following the Vite + React quick start guide(https://supabase.com/docs/guides/getting-started/quickstarts/reactjs).
2. create a hello-world Edge function and use the code in the CORS guide(https://supabase.com/docs/guides/functions/cors).
3. deploy the function using the Supabase CLI(https://supabase.com/docs/guides/functions/deploy).
Invoking the function from the app sometimes works, but sometimes it throws a CORS error, even though it then returns the data from the function. Refreshing the page a couple of times causes the CORS error to be thrown.
But this inconsistency breaks our production app.
Attaching a couple of screenshots with the code used.
Created a public repo with the code that causes the error. https://github.com/PaulMacinic/supabase-demo-cors
Also, deployed the frontend in the repo to Vercel. See here: https://supabase-demo-cors.vercel.app/
Tested on latest Chrome on Mac OS and latest Chrome on Windows.
Any idea would help a lot. Thanks!



4 Replies
The past couple of days several users here have posted issues including 500 on edge functions that where working. Here is one of the threads... https://discord.com/channels/839993398554656828/1184861607357075587/1185247528862625832
No answers yet, if they are even related to yours or each other.
Hi @garyaustin, thanks for getting back.
I have tried to search Discord and the GIthub issues before posting but unfortunately couldn't find any fix.
I thought this might be something to consider looking into since the error can be replicated by using the example code from the Supabase docs 😅
This is a user helping user forum mainly so a user would have to take you up on that. I really don't use edge functions currently myself. Filing an issue in github is where bugs are reported that are not specific to your instance running (ie getting support involved).
The randomness of the error is what makes me think it might be related to what the others are seeing and if so it might an infrastructure issue for some set of users.
Got it, thanks 👌