You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, @supabase/functions-js package automatically handles JSON/text/multipart-form/blob parsing. However, this is done simply by checking if Content-Type if one of three predefined options (see functions-js source code). In all other cases, response is converted to text.
Example
Supabase has defined following edge function:
// read-pdf-fileserve(async(req)=>{// read pdf file from S3 storage and return it as a responseconstpdfFile: Blob= ...
returnnewResponse(pdfFile,{headers: {// set correct content type"Content-Type": "application/pdf",},},);});
When this function is invoked via Supabase client:
const{ data }=awaitclient.functions.invoke(f,{method: 'GET'});// data is of type string, but should be Blob
As application/pdf is not one of three predefined content types, response is converted to text (in this line).
I know it is impossible to handle all possible content types, but defaulting to text might not be the best idea. Maybe you could add something like customResponseParser, which could be handled in a similar way to customFetch option already provided.
Does this make sense or am I missing something?
The text was updated successfully, but these errors were encountered:
Bug report
Describe the bug
Currently,
@supabase/functions-js
package automatically handles JSON/text/multipart-form/blob parsing. However, this is done simply by checking ifContent-Type
if one of three predefined options (see functions-js source code). In all other cases, response is converted to text.Example
Supabase has defined following edge function:
When this function is invoked via Supabase client:
As
application/pdf
is not one of three predefined content types, response is converted to text (in this line).I know it is impossible to handle all possible content types, but defaulting to text might not be the best idea. Maybe you could add something like
customResponseParser
, which could be handled in a similar way tocustomFetch
option already provided.Does this make sense or am I missing something?
The text was updated successfully, but these errors were encountered: