Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS/TS generated clients always set content-type of application/json, which makes uploading multipart/form-data difficult #1052

Open
macleodmac opened this issue Feb 28, 2024 · 0 comments · May be fixed by #1053

Comments

@macleodmac
Copy link

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:

  1. 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)
  2. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant