graphql-upload-ts icon indicating copy to clipboard operation
graphql-upload-ts copied to clipboard

Busboy dependency is expecting the Content-Type header key to be in lowercase.

Open hafaiedhmehdy opened this issue 1 year ago • 2 comments

Next.js API routes using graphql-upload-ts may encounter a "Missing Content-Type" error due to a case-sensitivity issue in the underlying Busboy dependency. Normalizing the Content-Type header before passing it to Busboy will resolve this issue.

hafaiedhmehdy avatar May 29 '24 15:05 hafaiedhmehdy

Busboy has another major issue where it looks for the Content-Type header incorrectly. In busboy/lib/index.js:53:11, it uses cfg.headers['content-type'], which will always return undefined. The correct way to retrieve the Content-Type header in Next.js is by using req.headers.get('content-type'). Just tagging you in jaydenseric, since it's your original project. And perhaps pass this down to the busboy team.

Edit: it's quite a mess, Next.js API's too different. :'( Another update: I'll be working towards achieving full compatibility between this repository's goal/function and Next.js.

ghost avatar May 29 '24 18:05 ghost

This solution addresses several issues, including the "Missing Content-Type" error caused by case-sensitivity in Busboy. My implementation ensures compatibility and smooth file upload functionality in Next.js environments.

This is an alpha version, and I'm looking for feedback and criticism to help improve it further. It's currently missing acknowledgements, so I welcome people to add themselves before I do, as I'm quite busy.

You can check out the solution here: graphql-upload-nextjs.

ghost avatar Jun 18 '24 19:06 ghost