From 11338dd0c594c7b1a11d130c093616379891e558 Mon Sep 17 00:00:00 2001 From: Alex Tugarev Date: Mon, 19 Apr 2021 07:40:29 +0000 Subject: [PATCH] [dashboard] redirect anonymous users to www. in SaaS context we want to redirect not logged in users from the root URL with no additional context provided to the website URL. fixes https://github.com/gitpod-io/gitpod/issues/3898 --- components/dashboard/src/App.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/dashboard/src/App.tsx b/components/dashboard/src/App.tsx index dfd579d764c1c9..0cbacf48a571e1 100644 --- a/components/dashboard/src/App.tsx +++ b/components/dashboard/src/App.tsx @@ -9,7 +9,7 @@ import Menu from './components/Menu'; import { BrowserRouter } from "react-router-dom"; import { Redirect, Route, Switch } from "react-router"; -import { Login } from './Login'; +import { Login, hasLoggedInBefore } from './Login'; import { UserContext } from './user-context'; import { getGitpodService } from './service/service'; import { shouldSeeWhatsNew, WhatsNew } from './WhatsNew'; @@ -71,6 +71,12 @@ function App() { } }, [localStorage.theme]); + if (window.location.pathname === '/' && window.location.hash === '' && !hasLoggedInBefore()) { + if (window.location.host === "gitpod.io" || window.location.host === "gitpod-staging.com") { + window.location.href = `https://www.${window.location.host}`; + } + } + if (loading) { return }