From 038f34b89a131551f628ca905e00d9b2b272c9b6 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Wed, 12 Aug 2020 18:21:38 -0400 Subject: [PATCH] Bugfix for application/wasm content-type being served with a charset value --- .proxyrc.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .proxyrc.js diff --git a/.proxyrc.js b/.proxyrc.js new file mode 100644 index 00000000..b6a52a81 --- /dev/null +++ b/.proxyrc.js @@ -0,0 +1,15 @@ +module.exports = function(app) { + // `app` is an Express instance + app.use(function(req, res, next) { + const sh = res.setHeader; + res.setHeader = function(key, value) { + // remove pointless/incorrect charset from binary responses: + if (/^content-type$/i.test(key)) { + const m = value && value.match(/^(image\/|application\/wasm); charset=.+$/); + if (m) value = m[1]; + } + return sh.call(this, key, value); + } + next(); + }); +};