diff --git a/web/packages/teleport/src/AppLauncher/AppLauncher.tsx b/web/packages/teleport/src/AppLauncher/AppLauncher.tsx index 32cc8a267d3b0..a7d0fb24d8d15 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`, { @@ -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 "${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; }