Unverified 提交 bc8166c2 authored 作者: Will Chen's avatar Will Chen 提交者: GitHub

Fix proxy server injection for gzip content (#190)

Some dev servers like next.js use Gzip which breaks our content injection so we avoid getting gzipped response when we need to do the shim injection.
上级 6e08bc5c
......@@ -181,6 +181,10 @@ const server = http.createServer((clientReq, clientRes) => {
delete headers.referer;
}
}
if (needsInjection) {
// Request uncompressed content from upstream
delete headers["accept-encoding"];
}
if (headers["if-none-match"] && needsInjection(target.pathname))
delete headers["if-none-match"];
......@@ -213,6 +217,11 @@ const server = http.createServer((clientReq, clientRes) => {
...upRes.headers,
"content-length": Buffer.byteLength(patched),
};
// If we injected content, it's no longer encoded in the original way
delete hdrs["content-encoding"];
// Also, remove ETag as content has changed
delete hdrs["etag"];
clientRes.writeHead(upRes.statusCode, hdrs);
clientRes.end(patched);
} catch (e) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论