com.jimuwd.xian.registry-proxy 1.0.99 → 1.0.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -198,14 +198,15 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
|
|
|
198
198
|
else {
|
|
199
199
|
// write back to client
|
|
200
200
|
// 准备通用响应头信息
|
|
201
|
-
const safeHeaders =
|
|
201
|
+
const safeHeaders = new Map();
|
|
202
|
+
safeHeaders.set("Content-Type", contentType);
|
|
202
203
|
// 复制所有可能需要的头信息(不包含安全相关的敏感头信息,如access-control-allow-origin、set-cookie、server、strict-transport-security等,这意味着代理服务器向下游客户端屏蔽了这些认证等安全数据)
|
|
203
204
|
// 也不能包含cf-cache-status、cf-ray(Cloudflare 特有字段)可能干扰客户端解析。
|
|
204
205
|
const headersToCopy = ['cache-control', 'connection', 'content-encoding', 'content-length', 'date', 'etag', 'last-modified', 'transfer-encoding', 'vary',];
|
|
205
206
|
headersToCopy.forEach(header => {
|
|
206
207
|
const value = upstreamResponse.headers.get(header);
|
|
207
208
|
if (value)
|
|
208
|
-
safeHeaders
|
|
209
|
+
safeHeaders.set(header, value);
|
|
209
210
|
});
|
|
210
211
|
// 必须使用 ServerResponse.setHeaders(safeHeaders)来覆盖现有headers而不是ServerResponse.writeHead(status,headers)来合并headers!
|
|
211
212
|
// 这个坑害我浪费很久事件来调试!
|