functions-js icon indicating copy to clipboard operation
functions-js copied to clipboard

Fixes missing body when Content-Type header supplied by developer

Open ggaabe opened this issue 1 year ago • 1 comments

What kind of change does this PR introduce?

Fixes null body when user supplies Content-Type in headers of supabase.functions.invoke, ie: invoked like this

  const response = await supabase.functions.invoke("stripe-webhook", {
    method: "POST",
    headers: {
   // this causes the body to be null
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      action: "finalizeClinicSetup",
      stripeSessionId,
      userId,
    }),
  });

What is the current behavior?

The request body sent over the network will be null, instead of the supplied body value, if a Content-Type header is supplied

Please link any relevant issues here.

What is the new behavior?

If user supplies a Content-Type header, the body will contain its original value supplied by the developer

ggaabe avatar Aug 04 '24 16:08 ggaabe

Just ran into this bug myself - took ages to debug - who would've thought the payload was not getting attached

vyder avatar Feb 28 '25 16:02 vyder

I want to know why this PR not merge into main branch? It's a frequently mentioned issue. :(

Efan404 avatar Jun 29 '25 14:06 Efan404

@Efan404 it doesn't seem like they really maintain this repo even though a lot relies on it

You might need to reach out to them to merge this through other channels

ggaabe avatar Jun 29 '25 15:06 ggaabe

Moved to https://github.com/supabase/supabase-js/pull/1758

mandarini avatar Oct 09 '25 12:10 mandarini