Open conor-odro opened 2 years ago
faced with the same issue
It's way better to check if it's a spec compliant FormData
You could use options?.body?.[Symbol.toStringTag] === 'FormData'
to check if it should or shouldn't delete the header.
instead of using if (isFormData(options.body) && isStandardBrowserEnv())
I recently came across an issue that is somewhat related to #16 where I was trying to upload a file to an AWS S3 bucket with a Presigned POST URL from inside a Manifest V3 Chrome Extension which requires the use of Service Workers.
Unfortunately this was erroring due to the
Content-Type
header being set toapplication/www-x-form-urlencoded
instead ofmultipart/form-data
and the WebKit boundary injected by the browser.Looking into the code it seems the issue is caused by the use of
isStandardBrowserEnv()
inside the check which should automatically remove theContent-Type
header, allowing the browser to fill in the correct one. This helper method is expectingwindow
anddocument
to be defined which is not possible in a Service Worker environment.@vespaiach Removing the
isStandardBrowserEnv()
from the if statement solves my problem and allows the file upload to succeed, but I am unsure if it will have any knock on effect to other use cases of this package?