cli: `supabase functions serve [--all]` unusable since CLI v1.50.1 (blocked by CORS error on preflight requests)

It is not possible to use supabase functions serve anymore in a local environment since v1.49.0

All edge functions requests are blocked due to CORS rules. This is due to the edge-runtime returning 408 - Request timeout on all preflight OPTIONS requests.

Screenshots courtesy of user @joshmarnold

CleanShot_2023-04-16_at_11 09 32 CleanShot_2023-04-15_at_19 53 36 CleanShot_2023-04-15_at_19 55 00 CleanShot_2023-04-15_at_19 54 49

Please see full report on the underlying edge-runtime issue at : https://github.com/supabase/edge-runtime/issues/50

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 6
  • Comments: 28 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Working again for me with latest version. Thanks for the work!

Problem solved ! Many many thanks

@vejja Can you try upgrading to Supabase CLI 1.52.3+ to see if you still experience these issues?

Ok sorry, it was my mistake to assume that serve [--all] was being done by deno-relay - as I did not notice the edge-runtime container in older versions of the stack. BTW now that I understand that the edge-runtime used to be able to properly serve requests without a body, I guess it will be easier to track down the change that introduced the issue. Looking forward to examining this.

I see. We probably misunderstood each other because deno relay doesn’t support serving multiple functions. We can revert to an older version of edge runtime image to support serve [--all]. It will likely break other things like import map and --no-verify-jwt flag but it sounds to me serving cors compliant requests is more important.

An alternative is to exclude edge runtime from starting automatically with -x flag, ie.

supabase start -x edge-runtime

After that you can serve the function with deno-relay as mentioned.

I’m not sure if reverting is necessary given the above workaround?

Only works if I want to serve a single function, in which case your workaround works. But running supabase functions serve [--all] pulls the edge-runtime docker container and starts it anyway.

The use case for running supabase functions serve [--all] is for people who have split their code across multiple functions - which is my case. I cannot serve my code base anymore due to the bug. Given that the only purpose of supabase functions serve [--all] is to address this use case, I do think that reverting is necessary while the fix is being worked on.

In addition, given that the edge-runtime cannot serve CORS-compliant requests, I don’t see the point of maintaining it in the CLI for now ?

An alternative is to exclude edge runtime from starting automatically with -x flag, ie.

supabase start -x edge-runtime

After that you can serve the function with deno-relay as mentioned.

I’m not sure if reverting is necessary given the above workaround?

I felt I would add a bit more context here for people to better understand the issue:

This bug actually prevents any local development of edge functions

When supabase-js tries to invoke an edge function, the browser will always send an OPTIONS request first. Because that preflight request errors out with 408, the browser CORS rules then prohibit the invoke call. So, something that apparently only touches OPTIONS requests, in fact blocks all requests.

To be clear, it is not possible to use edge functions anymore since CLI v.1.49.0

I will change the title of the issue to better call the attention on the main problem.

Also ran into this when trying to write a supabase edge function for the first time and it definitely caused some frustration (I obviously assumed the problem was on my side).

Additionally when supabase is installed via brew, there isn’t an easy way to downgrade your client.

Wouldn’t it be possible to pin the cli to an older edge runtime version, until this is fixed?