The NIP-96 uploadFile has a bug. This PR fixes it.
When using fetch API along with FormData, specifying Content-Type will cause error. It is because if we specify Content-Type: multipart/form-data, the browser will send it as is without considering "boundary".
Warning: When using FormData to submit POST requests using XMLHttpRequest or the Fetch API with the multipart/form-data content type (e.g. when uploading files and blobs to the server), do not explicitly set the Content-Type header on the request. Doing so will prevent the browser from being able to set the Content-Type header with the boundary expression it will use to delimit form fields in the request body.
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest_API/Using_FormData_Objects#sending_files_using_a_formdata_object
The browser will detect Content-Type from body and append boundary=... appropriately. We don't need to specify Content-Type.
Why
The NIP-96 uploadFile has a bug. This PR fixes it.
When using
fetch
API along withFormData
, specifyingContent-Type
will cause error. It is because if we specifyContent-Type: multipart/form-data
, the browser will send it as is without considering "boundary".The browser will detect
Content-Type
frombody
and appendboundary=...
appropriately. We don't need to specifyContent-Type
.References