com.jimuwd.xian.registry-proxy 1.0.27 → 1.0.28

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 CHANGED
@@ -214,10 +214,10 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
214
214
  return;
215
215
  }
216
216
  const contentLength = successResponse.headers.get('Content-Length');
217
- const safeHeaders = {
218
- 'Content-Type': successResponse.headers.get('Content-Type') || undefined,
219
- 'Content-Length': contentLength && !isNaN(Number(contentLength)) ? contentLength : undefined,
220
- };
217
+ const safeHeaders = {};
218
+ safeHeaders["content-type"] = contentType;
219
+ if (contentLength && !isNaN(Number(contentLength)))
220
+ safeHeaders["content-length"] = contentLength;
221
221
  res.writeHead(successResponse.status, safeHeaders);
222
222
  successResponse.body.pipe(res).on('error', (err) => {
223
223
  console.error(`Stream error for ${relativePathPrefixedWithSlash}:`, err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.jimuwd.xian.registry-proxy",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "type": "module",
5
5
  "description": "A lightweight npm registry proxy with fallback support",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -266,10 +266,9 @@ export async function startProxyServer(
266
266
  return;
267
267
  }
268
268
  const contentLength = successResponse.headers.get('Content-Length');
269
- const safeHeaders: OutgoingHttpHeaders = {
270
- 'Content-Type': successResponse.headers.get('Content-Type') || undefined,
271
- 'Content-Length': contentLength && !isNaN(Number(contentLength)) ? contentLength : undefined,
272
- };
269
+ const safeHeaders: OutgoingHttpHeaders = {};
270
+ safeHeaders["content-type"] = contentType;
271
+ if (contentLength && !isNaN(Number(contentLength))) safeHeaders["content-length"] = contentLength;
273
272
  res.writeHead(successResponse.status, safeHeaders);
274
273
  successResponse.body.pipe(res).on('error', (err: any) => {
275
274
  console.error(`Stream error for ${relativePathPrefixedWithSlash}:`, err);