From 2b50fe75c4679c532611bd63aa837c76ac350b7d Mon Sep 17 00:00:00 2001 From: Gabriel Corado Date: Tue, 2 May 2023 22:05:33 -0300 Subject: [PATCH 1/4] feat(web): add network error message for app launch --- web/packages/teleport/src/AppLauncher/AppLauncher.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/packages/teleport/src/AppLauncher/AppLauncher.tsx b/web/packages/teleport/src/AppLauncher/AppLauncher.tsx index 32cc8a267d3b0..207f58923c6be 100644 --- a/web/packages/teleport/src/AppLauncher/AppLauncher.tsx +++ b/web/packages/teleport/src/AppLauncher/AppLauncher.tsx @@ -72,7 +72,11 @@ export function AppLauncher() { window.location.replace(`https://${fqdn}${port}${path}`); } catch (err) { let statusText = 'Something went wrong'; - if (err instanceof Error) { + + if (err instanceof TypeError) { + // `fetch` returns `TypeError` when there is a network error. + statusText = `Unable to access "${params.fqdn}" due to a network issue. Please ensure the domain is configured correctly, and your browser trusts the SSL certificate.` + } else if (err instanceof Error) { statusText = err.message; } From e7d0ec29a21564782825d88c1da93478a36abde0 Mon Sep 17 00:00:00 2001 From: Gabriel Corado Date: Wed, 3 May 2023 17:31:38 -0300 Subject: [PATCH 2/4] Update web/packages/teleport/src/AppLauncher/AppLauncher.tsx Co-authored-by: Roman Tkachenko --- web/packages/teleport/src/AppLauncher/AppLauncher.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/packages/teleport/src/AppLauncher/AppLauncher.tsx b/web/packages/teleport/src/AppLauncher/AppLauncher.tsx index 207f58923c6be..5a1b2fbe79d24 100644 --- a/web/packages/teleport/src/AppLauncher/AppLauncher.tsx +++ b/web/packages/teleport/src/AppLauncher/AppLauncher.tsx @@ -75,7 +75,7 @@ export function AppLauncher() { if (err instanceof TypeError) { // `fetch` returns `TypeError` when there is a network error. - statusText = `Unable to access "${params.fqdn}" due to a network issue. Please ensure the domain is configured correctly, and your browser trusts the SSL certificate.` + statusText = `Unable to access "${params.fqdn}". This may happen if your Teleport Proxy is using untrusted or self-signed certificate. Please ensure Teleport Proxy service uses valid certificate or access the application domain directly () and accept the certificate exception from your browser.` } else if (err instanceof Error) { statusText = err.message; } From 8f1c696796c32ec6ec73648f7fa1ee517c5a20ec Mon Sep 17 00:00:00 2001 From: Gabriel Corado Date: Wed, 3 May 2023 17:44:31 -0300 Subject: [PATCH 3/4] refactor(web): update error message --- web/packages/teleport/src/AppLauncher/AppLauncher.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/packages/teleport/src/AppLauncher/AppLauncher.tsx b/web/packages/teleport/src/AppLauncher/AppLauncher.tsx index 5a1b2fbe79d24..299c97f8999d2 100644 --- a/web/packages/teleport/src/AppLauncher/AppLauncher.tsx +++ b/web/packages/teleport/src/AppLauncher/AppLauncher.tsx @@ -35,11 +35,12 @@ export function AppLauncher() { const queryParams = new URLSearchParams(search); const createAppSession = useCallback(async (params: UrlLauncherParams) => { + let fqdn = params.fqdn; + const port = location.port ? `:${location.port}` : ''; + try { - let fqdn = params.fqdn; if (!fqdn) { const app = await service.getAppFqdn(params); - fqdn = app.fqdn; } @@ -48,7 +49,6 @@ export function AppLauncher() { params.arn = decodeURIComponent(params.arn); } - const port = location.port ? `:${location.port}` : ''; const session = await service.createAppSession(params); await fetch(`https://${fqdn}${port}/x-teleport-auth`, { @@ -75,7 +75,7 @@ export function AppLauncher() { if (err instanceof TypeError) { // `fetch` returns `TypeError` when there is a network error. - statusText = `Unable to access "${params.fqdn}". This may happen if your Teleport Proxy is using untrusted or self-signed certificate. Please ensure Teleport Proxy service uses valid certificate or access the application domain directly () and accept the certificate exception from your browser.` + statusText = `Unable to access "${fqdn}". This may happen if your Teleport Proxy is using untrusted or self-signed certificate. Please ensure Teleport Proxy service uses valid certificate or access the application domain directly (https://${fqdn}${port}) and accept the certificate exception from your browser.` } else if (err instanceof Error) { statusText = err.message; } From 136e89c781a35fef084d46ca3d2f29e08020ff36 Mon Sep 17 00:00:00 2001 From: Gabriel Corado Date: Wed, 3 May 2023 17:49:35 -0300 Subject: [PATCH 4/4] chore(web): fix linter --- web/packages/teleport/src/AppLauncher/AppLauncher.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/packages/teleport/src/AppLauncher/AppLauncher.tsx b/web/packages/teleport/src/AppLauncher/AppLauncher.tsx index 299c97f8999d2..a7d0fb24d8d15 100644 --- a/web/packages/teleport/src/AppLauncher/AppLauncher.tsx +++ b/web/packages/teleport/src/AppLauncher/AppLauncher.tsx @@ -75,7 +75,7 @@ export function AppLauncher() { if (err instanceof TypeError) { // `fetch` returns `TypeError` when there is a network error. - statusText = `Unable to access "${fqdn}". This may happen if your Teleport Proxy is using untrusted or self-signed certificate. Please ensure Teleport Proxy service uses valid certificate or access the application domain directly (https://${fqdn}${port}) and accept the certificate exception from your browser.` + statusText = `Unable to access "${fqdn}". This may happen if your Teleport Proxy is using untrusted or self-signed certificate. Please ensure Teleport Proxy service uses valid certificate or access the application domain directly (https://${fqdn}${port}) and accept the certificate exception from your browser.`; } else if (err instanceof Error) { statusText = err.message; }