http-proxy-middleware
Advanced tools
Comparing version 1.2.0 to 1.2.1-alpha.1
@@ -31,4 +31,4 @@ "use strict"; | ||
_proxyRes.on('end', () => __awaiter(this, void 0, void 0, function* () { | ||
// set original content type from upstream | ||
res.setHeader('content-type', originalProxyRes.headers['content-type'] || ''); | ||
// copy original headers | ||
copyHeaders(proxyRes, res); | ||
// call interceptor with intercepted response (buffer) | ||
@@ -74,1 +74,30 @@ const interceptedBuffer = Buffer.from(yield interceptor(buffer, originalProxyRes, req, res)); | ||
} | ||
/** | ||
* Copy original headers | ||
* https://github.com/apache/superset/blob/9773aba522e957ed9423045ca153219638a85d2f/superset-frontend/webpack.proxy-config.js#L78 | ||
*/ | ||
function copyHeaders(originalResponse, response) { | ||
response.statusCode = originalResponse.statusCode; | ||
response.statusMessage = originalResponse.statusMessage; | ||
if (response.setHeader) { | ||
let keys = Object.keys(originalResponse.headers); | ||
// ignore chunked, brotli, gzip, deflate headers | ||
keys = keys.filter((key) => !['content-encoding', 'transfer-encoding'].includes(key)); | ||
keys.forEach((key) => { | ||
let value = originalResponse.headers[key]; | ||
if (key === 'set-cookie') { | ||
// remove cookie domain | ||
value = Array.isArray(value) ? value : [value]; | ||
value = value.map((x) => x.replace(/Domain=[^;]+?/i, '')); | ||
} | ||
else if (key === 'location') { | ||
// set redirects to use local URL | ||
// value = (value || '').replace(target, ''); // TODO | ||
} | ||
response.setHeader(key, value); | ||
}); | ||
} | ||
else { | ||
response.headers = originalResponse.headers; | ||
} | ||
} |
{ | ||
"name": "http-proxy-middleware", | ||
"version": "1.2.0", | ||
"version": "1.2.1-alpha.1", | ||
"description": "The one-liner node.js proxy middleware for connect, express and browser-sync", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73965
942
1