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

Errors caused by default content-type #1298

Closed
HHongSeungWoo opened this issue Aug 16, 2023 · 2 comments · Fixed by #1314
Closed

Errors caused by default content-type #1298

HHongSeungWoo opened this issue Aug 16, 2023 · 2 comments · Fixed by #1314

Comments

@HHongSeungWoo
Copy link
Contributor

HHongSeungWoo commented Aug 16, 2023

https://github.com/drwpow/openapi-typescript/blob/ad894a5697f852709c745c22e974991b9b8b4925/packages/openapi-fetch/src/index.ts#L3C8-L3C8

If the request headers has content-type and the body is empty, Fastify does not process the request and returns an error.
Is there a reason to set content-type: application/json as the default headers?

@drwpow
Copy link
Contributor

drwpow commented Aug 20, 2023

I thought that all JSON APIs expected "Content-Type": "application/json"? This is the first I’ve heard of it causing issues.

But you do have a good point which is it’s impossible to unset default headers in the client. While I think "Content-Type": "application/json" is a good default, you should still be able to unset that if desired.

@drwpow
Copy link
Contributor

drwpow commented Aug 20, 2023

Starting in 0.7.4 you can unset the default headers with:

createClient({ headers: { "content-type": null } })

Note: undefined will just be ignored; null is required to unset

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.

2 participants