Skip to content

Body does not seem properly formated and cors error #12

@GaryAustin1

Description

@GaryAustin1

Bug report

The documentation shows calling a function as:

const { data: user, error } = await supabase.functions.invoke('hello', {
  responseType: 'text',
  body: { foo: 'bar' }
})

The function.js code has

const response = await this.fetch(`${this.url}/${functionName}`, {
        method: 'POST',
        headers: Object.assign({}, this.headers, headers),
        body,
      })

I would think at a minimum body should be body:body.
Very strange results occur, but basically content length is string length if {body:'string'} is used in call.
If an object is used {body:{k:'v'}, length is always 15 probably an error message for invalid object or something...

Not sure if it is related. But all calls generate cors errors:

image

To Reproduce

Follow the instructions for functions invoke in api reference.

Expected behavior

Body should be formatted correctly and no cors error (if not related)

System information

Latest supabase.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions