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
When performing file uploads to raw endpoints using multipart/form-data we need to set a boundary in the Content-Type header to delineate the different parts of the request payload. fetch handles this natively for us when a FormData object is passed to it.
The auto-generated JS/TS clients are configured to set the Content-Type header to application/json for every request, without exception. Currently we can pass an overridden header for Content-Type, but that requires us to handle the boundary manually, which is not great.
Our options are to:
In our overridden fetch implementation, check the type of the body and delete the application/json header if present (as it's already set at this point)
Only set the application/json header if the body is not FormData, as in these cases we should allow fetch to natively handle the setting of Content-Type including boundary
The text was updated successfully, but these errors were encountered:
When performing file uploads to raw endpoints using multipart/form-data we need to set a boundary in the
Content-Type
header to delineate the different parts of the request payload.fetch
handles this natively for us when a FormData object is passed to it.The auto-generated JS/TS clients are configured to set the
Content-Type
header to application/json for every request, without exception. Currently we can pass an overridden header forContent-Type
, but that requires us to handle the boundary manually, which is not great.Our options are to:
fetch
implementation, check the type of the body and delete theapplication/json
header if present (as it's already set at this point)application/json
header if the body is notFormData
, as in these cases we should allow fetch to natively handle the setting ofContent-Type
including boundaryThe text was updated successfully, but these errors were encountered: