From 1a8727f565ee20f7ec37d286fbbcc549594032b6 Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Tue, 3 Aug 2021 10:24:14 +0300 Subject: [PATCH] If internal links are not specified, the external one should be used (#1161) * Don't set public url value to internal url settings. Fix hang loading che-theia when internal network disabled. Signed-off-by: Oleksandr Andriienko --- .../src/node/che-plugin-service.ts | 6 +++--- .../src/node/che-server-http-service-impl.ts | 2 +- .../src/node/che-server-remote-api-impl.ts | 11 +++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/extensions/eclipse-che-theia-plugin-ext/src/node/che-plugin-service.ts b/extensions/eclipse-che-theia-plugin-ext/src/node/che-plugin-service.ts index 458b87d6e..bb4b01b77 100644 --- a/extensions/eclipse-che-theia-plugin-ext/src/node/che-plugin-service.ts +++ b/extensions/eclipse-che-theia-plugin-ext/src/node/che-plugin-service.ts @@ -98,9 +98,9 @@ export class ChePluginServiceImpl implements ChePluginService { try { const workspaceSettings: WorkspaceSettings = await this.workspaceService.getWorkspaceSettings(); - if (workspaceSettings && workspaceSettings[PLUGIN_REGISTRY_INTERNAL_URL]) { - const uri = workspaceSettings[PLUGIN_REGISTRY_INTERNAL_URL]; - const publicUri = workspaceSettings[PLUGIN_REGISTRY_URL] || uri; + if (workspaceSettings) { + const publicUri = workspaceSettings[PLUGIN_REGISTRY_URL]; + const uri = workspaceSettings[PLUGIN_REGISTRY_INTERNAL_URL] || publicUri; this.defaultRegistry = { name: 'Eclipse Che plugins', diff --git a/extensions/eclipse-che-theia-remote-impl-che-server/src/node/che-server-http-service-impl.ts b/extensions/eclipse-che-theia-remote-impl-che-server/src/node/che-server-http-service-impl.ts index bc9bc02f0..196467c48 100644 --- a/extensions/eclipse-che-theia-remote-impl-che-server/src/node/che-server-http-service-impl.ts +++ b/extensions/eclipse-che-theia-remote-impl-che-server/src/node/che-server-http-service-impl.ts @@ -47,7 +47,7 @@ export class CheServerHttpServiceImpl implements HttpService { const certificateAuthority = await this.certificateService.getCertificateAuthority(); const proxyUrl = process.env.http_proxy; - const baseUrl = process.env.CHE_API; + const baseUrl = process.env.CHE_API_EXTERNAL; console.log('proxyUrl && proxyUrl !== && baseUrl', proxyUrl && proxyUrl !== '' && baseUrl); if (proxyUrl && proxyUrl !== '' && baseUrl) { const parsedBaseUrl = url.parse(baseUrl); diff --git a/extensions/eclipse-che-theia-remote-impl-che-server/src/node/che-server-remote-api-impl.ts b/extensions/eclipse-che-theia-remote-impl-che-server/src/node/che-server-remote-api-impl.ts index e5ded6e80..a5d9ba617 100644 --- a/extensions/eclipse-che-theia-remote-impl-che-server/src/node/che-server-remote-api-impl.ts +++ b/extensions/eclipse-che-theia-remote-impl-che-server/src/node/che-server-remote-api-impl.ts @@ -24,14 +24,13 @@ export class CheServerRemoteApiImpl { * baseAPIUrl - responsible for storing base url to API service, taken from environment variable * machineToken - machine token taken from environment variable, always the same at workspace lifecycle */ - private readonly baseAPIUrl: string; + private readonly baseAPIUrl: string | undefined; private readonly machineToken: string; constructor() { - if (process.env.CHE_API_INTERNAL === undefined) { - console.error('Unable to create Che API REST Client: "CHE_API_INTERNAL" is not set.'); - } else { - this.baseAPIUrl = process.env.CHE_API_INTERNAL; + this.baseAPIUrl = process.env.CHE_API_INTERNAL || process.env.CHE_API_EXTERNAL; + if (!this.baseAPIUrl) { + console.error('Unable to create Che API REST client: "CHE_API" is not set'); } if (process.env.CHE_MACHINE_TOKEN === undefined) { @@ -52,6 +51,6 @@ export class CheServerRemoteApiImpl { } getCheApiURI(): string { - return this.baseAPIUrl; + return this.baseAPIUrl!; } }