Netlify Adapter does not return properly formed response for binary data #4174
Labels
bug
Something isn't working
help wanted
PRs welcomed. The implementation details are unlikely to cause debate
p2-nice-to-have
SvelteKit cannot be used by a small number of people, quality of life improvements, etc.
pkg:adapter-netlify
Milestone
Describe the bug
In order to return binary data (eg. a generated Image) from a Netlify function, the data must be converted to a
base64
encoded string with the proper content-type.This is done in
handler.js
, but the condition that checks forUint8Array
will always fail, as the response type changed with #3384From what I can tell, there is currently no way to determine the "type" from the response, other than looking at the
content-type
header and using something likeis_text
Reproduction
Here's a minimal setup: https://github.com/bummzack/sveltekit-netlify-binary-response
There's twice the same code running in a SvelteKit Endpoint (
image.png
) and a separate Netlify function.The SvelteKit endpoint does not encode the image properly and it won't be displayed:
https://elated-knuth-7439db.netlify.app/image.png
The direct implementation as a separate Netlify function works as expected:
https://elated-knuth-7439db.netlify.app/.netlify/functions/test
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: