-
-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
res.send(Buffer.from(someString)) overwriting Content-Type response header #4138
Comments
I believe this is not an override like the linked issue, but is a feature of using res.set instead of res.setHeader where res.set will add the standard charset if not supplied where res.setHeader will use your header as-is. |
Thanks for your input. Using |
Ok. I will close for now until there is a reproduction we can look into to determine what is going wrong. Here is a terminal session of me trying to reproduce the issue. Perhaps you can provide something similar? Not sure if maybe there is something else at play in your setup adding the charset or something.
You can see in the cURL output, the response header is just |
I've got this express (4.17.1) app running on Node.js (12.14.0):
In serving the .json file, I am trying to set the
Content-Type
response header toapplication/json
, but Express appears to be overwriting it withapplication/json; charset=utf-8
.This appears to be normal behavior usually, but the docs and this previous issue seem to say that Express shouldn't overwrite the
Content-Type
response header whenres.send()
is passed aBuffer
object.Am I missing something, or is the documentation incorrect? If the documentation is incorrect and this is normal behavior, is there another way I can prevent Express from automatically overwriting the
Content-Type
response header?For extra context: this is an issue related to configuring an application's publisher domain in Azure.
The text was updated successfully, but these errors were encountered: