com.jimuwd.xian.registry-proxy 1.0.105 → 1.0.107
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 +7 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -159,12 +159,16 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
|
|
|
159
159
|
if (!upstreamResponse.ok)
|
|
160
160
|
throw new Error("Only 2xx upstream response is supported");
|
|
161
161
|
try {
|
|
162
|
-
const contentType = upstreamResponse.headers.get("content-type")
|
|
162
|
+
const contentType = upstreamResponse.headers.get("content-type") /*|| "application/octet-stream"*/;
|
|
163
|
+
if (!contentType) {
|
|
164
|
+
logger.error(`Response from upstream content-type header is absent, ${targetUrl} `);
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
163
167
|
if (contentType.includes('application/json')) { // JSON 处理逻辑
|
|
164
168
|
const data = await upstreamResponse.json();
|
|
165
169
|
if (data.versions) { // 处理node依赖包元数据
|
|
166
170
|
logger.info("Write package meta data application/json response from upstream to downstream", targetUrl);
|
|
167
|
-
const host = reqFromDownstreamClient.headers.host || `
|
|
171
|
+
const host = reqFromDownstreamClient.headers.host || `127.0.0.1:${proxyPort}`;
|
|
168
172
|
const baseUrl = `${proxyInfo.https ? 'https' : 'http'}://${host}${proxyInfo.basePath === '/' ? '' : proxyInfo.basePath}`;
|
|
169
173
|
for (const versionKey in data.versions) {
|
|
170
174
|
const packageVersion = data.versions[versionKey];
|
|
@@ -398,7 +402,7 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
|
|
|
398
402
|
proxyPort = address.port;
|
|
399
403
|
const portFile = join(process.env.PROJECT_ROOT || process.cwd(), '.registry-proxy-port');
|
|
400
404
|
writeFile(portFile, proxyPort.toString()).catch(e => logger.error('Failed to write port file:', e));
|
|
401
|
-
logger.info(`Proxy server running on ${proxyInfo.https ? 'https' : 'http'}://
|
|
405
|
+
logger.info(`Proxy server running on ${proxyInfo.https ? 'https' : 'http'}://127.0.0.1:${proxyPort}${basePathPrefixedWithSlash === '/' ? '' : basePathPrefixedWithSlash}`);
|
|
402
406
|
resolve(server);
|
|
403
407
|
});
|
|
404
408
|
});
|