Closed silasabbott closed 7 months ago
You could try using https://github.com/lquixada/cross-fetch instead of node's fetch function.
If that doesn't work, could you submit a PR for this one?
cross-fetch
worked as a workaround 🎉
Some frameworks already use custom fetch implementations for routing/caching/etc, so this solution might not work for everyone. I'll close for now, but if others are getting stuck on this we can re-open and get a permanent fix going.
Sounds good.
When uploading an image Buffer in Node, lemmy is returning:
I think content-type headers are automatically set by fetch in the browser, but Node's fetch does not automatically set content-type headers and multipart boundaries when posting a form. This might be fixed by combining the headers generated by the form-data lib with user-defined headers here:
...or using the
formData.submit
method (although then you'd loose the custom fetch function).Also important to note that form-data does not support File objects, so trying to upload an image File in Node throws: