com.jimuwd.xian.registry-proxy 1.0.38 → 1.0.39

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
@@ -165,7 +165,9 @@ async function writeSuccessfulResponse(registryInfo, targetUrl, res, response, r
165
165
  if (!response.ok)
166
166
  throw new Error("Only 2xx response is supported");
167
167
  try {
168
- const contentType = response.headers.get('Content-Type') || 'application/octet-stream';
168
+ const upstreamContentType = response.headers.get('Content-Type');
169
+ console.log("Upstream Content-Type", upstreamContentType);
170
+ const contentType = upstreamContentType || 'application/octet-stream';
169
171
  // 准备通用头信息
170
172
  const safeHeaders = {
171
173
  'content-type': contentType,
@@ -194,7 +196,6 @@ async function writeSuccessfulResponse(registryInfo, targetUrl, res, response, r
194
196
  const path = removeRegistryPrefix(tarball, registryInfos);
195
197
  const proxiedTarballUrl = `${baseUrl}${path}${new URL(tarball).search || ''}`;
196
198
  data.versions[version].dist.tarball = proxiedTarballUrl;
197
- console.log("proxiedTarballUrl", proxiedTarballUrl);
198
199
  }
199
200
  }
200
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.jimuwd.xian.registry-proxy",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
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
@@ -228,7 +228,9 @@ async function writeSuccessfulResponse(
228
228
  if (!response.ok) throw new Error("Only 2xx response is supported");
229
229
 
230
230
  try {
231
- const contentType = response.headers.get('Content-Type') || 'application/octet-stream';
231
+ const upstreamContentType = response.headers.get('Content-Type');
232
+ console.log("Upstream Content-Type", upstreamContentType);
233
+ const contentType = upstreamContentType || 'application/octet-stream';
232
234
 
233
235
  // 准备通用头信息
234
236
  const safeHeaders: OutgoingHttpHeaders = {
@@ -261,9 +263,8 @@ async function writeSuccessfulResponse(
261
263
  const tarball = data.versions[version]?.dist?.tarball;
262
264
  if (tarball) {
263
265
  const path = removeRegistryPrefix(tarball, registryInfos);
264
- const proxiedTarballUrl = `${baseUrl}${path}${new URL(tarball).search || ''}`;
265
- data.versions[version]!.dist!.tarball = proxiedTarballUrl;
266
- console.log("proxiedTarballUrl", proxiedTarballUrl);
266
+ const proxiedTarballUrl: string = `${baseUrl}${path}${new URL(tarball).search || ''}`;
267
+ data.versions[version]!.dist!.tarball = proxiedTarballUrl as string;
267
268
  }
268
269
  }
269
270
  }