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

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

Open
hafaiedhmehdy opened this issue May 29, 2024 · 2 comments

Comments

@hafaiedhmehdy
Copy link

hafaiedhmehdy commented May 29, 2024

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
Copy link
Author

hafaiedhmehdy commented May 29, 2024

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.

@hafaiedhmehdy
Copy link
Author

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.

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

No branches or pull requests

1 participant