-
-
Notifications
You must be signed in to change notification settings - Fork 380
Unwanted charset=UTF-8 always added to custom mime types #350
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
Comments
@gpoitch hm, sound reasonable, any ideas how we can detect when we need add |
@evilebottnawi yes, after some digging looks like it should be added only if charset is defined for the type in mime-db (https://github.com/jshttp/mime-db/blob/master/db.json). We could conditionally add charset based on that instead. |
@gpoitch 👍 PR welcome and when we release new version |
/cc @hiroppy I think we should not change logic, same logic using in many places in express and express middleware https://github.com/expressjs/serve-index/blob/master/index.js#L543, i think will be great implement an option for this |
hmm, it seems we need to overwrite below lines.
Yes, I agree with you. We need to provide a new option for overwriting this. |
ok, I'll take over this. |
Just for information, https://github.com/expressjs/serve-static/blob/master/index.js do not use |
This problem seems to be difficult because express is writing utf-8 directly.😥 |
Fixed in |
Since #136,
charset=UTF-8
is always appended to the Content-Type header. If I define custom mime types, I believe that this shouldn't be appended.For example, mobile safari can render 3d/AR models in a native viewer when a file is served with
model/vnd.pixar.usd
. When setting the optionmimeTypes: { 'model/vnd.pixar.usd', ['usdz'] }
, the server will return:Content-Type: model/vnd.pixar.usd; charset=UTF-8
. The addition of the charset causes the browser to incorrectly interpret the mime type.This is already special-cased for wasm.
Expected Behavior
charset=UTF-8 is not appended to every Content-Type header when defining custom mimeTypes.
Actual Behavior
charset=UTF-8 is always appended
I can make a PR if you agree on the proposed behavior.
The text was updated successfully, but these errors were encountered: