This repository demonstrates an issue where openapi-fetch
sends a Content-Length
header that is twice as large as expected for file uploads, compared to using plain fetch.
-
Clone the repository:
-
Install dependencies and run the project:
pnpm install pnpm dev
-
Access the UI: Open your browser to
http://localhost:5173
(or the port indicated by Vite). -
Upload and test:
- Select a file using the file input.
- Open your backend console (where
pnpm dev
is running). - Click each of the three buttons:
- "Upload with plain fetch"
- "Upload with new Request"
- "Upload with openapi-fetch"
-
Observe the
Content-Length
: In the backend console, you will observe theContent-Length
header logged for each upload. TheContent-Length
for "Upload with plain fetch" will be approximately half the size of theContent-Length
for "Upload with new Request" and "Upload with openapi-fetch". This highlights the unexpected largerContent-Length
sent whennew Request
(used internally byopenapi-fetch
) is involved in file uploads.