Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Update redirects to /projects to /project/default is on self hosted

Joshen Limc0b36cbe1ed1
diff --git a/studio/components/interfaces/App/RouteValidationWrapper.tsx b/studio/components/interfaces/App/RouteValidationWrapper.tsx
index 9fd0b0c8cbf..c33cb43bc44 100644
--- a/studio/components/interfaces/App/RouteValidationWrapper.tsx
+++ b/studio/components/interfaces/App/RouteValidationWrapper.tsx
@@ -2,12 +2,12 @@ import { observer } from 'mobx-react-lite'
import { useRouter } from 'next/router'
import { PropsWithChildren, useEffect } from 'react'
+import { useParams } from 'common'
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
import { useProjectsQuery } from 'data/projects/projects-query'
import { useFlag, useStore } from 'hooks'
import useLatest from 'hooks/misc/useLatest'
-import { useParams } from 'common'
-import { LOCAL_STORAGE_KEYS } from 'lib/constants'
+import { DEFAULT_HOME, LOCAL_STORAGE_KEYS } from 'lib/constants'
// Ideally these could all be within a _middleware when we use Next 12
const RouteValidationWrapper = ({ children }: PropsWithChildren<{}>) => {
@@ -51,7 +51,7 @@ const RouteValidationWrapper = ({ children }: PropsWithChildren<{}>) => {
if (!isValidOrg) {
ui.setNotification({ category: 'error', message: 'This organization does not exist' })
- router.push(navLayoutV2 ? `/org/${organizations[0].slug}` : '/projects')
+ router.push(navLayoutV2 ? `/org/${organizations[0].slug}` : DEFAULT_HOME)
return
}
}
@@ -71,7 +71,7 @@ const RouteValidationWrapper = ({ children }: PropsWithChildren<{}>) => {
if (!isValidProject) {
ui.setNotification({ category: 'error', message: 'This project does not exist' })
- router.push(navLayoutV2 ? `/org/${organizations?.[0].slug}` : '/projects')
+ router.push(navLayoutV2 ? `/org/${organizations?.[0].slug}` : DEFAULT_HOME)
return
}
}
diff --git a/studio/lib/constants/index.ts b/studio/lib/constants/index.ts
index 3e3b66f24b2..1d300a43fd2 100644
--- a/studio/lib/constants/index.ts
+++ b/studio/lib/constants/index.ts
@@ -2,6 +2,7 @@ export * from './infrastructure'
export * from './metrics'
export const IS_PLATFORM = process.env.NEXT_PUBLIC_IS_PLATFORM === 'true'
+export const DEFAULT_HOME = IS_PLATFORM ? '/projects' : 'project/default'
export const API_URL = IS_PLATFORM ? process.env.NEXT_PUBLIC_API_URL : '/api'
export const API_ADMIN_URL = IS_PLATFORM ? process.env.NEXT_PUBLIC_API_ADMIN_URL : undefined
export const PG_META_URL = IS_PLATFORM
diff --git a/studio/lib/gotrue.ts b/studio/lib/gotrue.ts
index 9a285edf300..d83f9e902c9 100644
--- a/studio/lib/gotrue.ts
+++ b/studio/lib/gotrue.ts
@@ -1,5 +1,6 @@
import { User } from '@supabase/gotrue-js'
import { gotrueClient } from 'common'
+import { DEFAULT_HOME, IS_PLATFORM } from './constants'
export { STORAGE_KEY } from 'common'
export const auth = gotrueClient
@@ -36,7 +37,7 @@ export const getIdentity = (gotrueUser: User) => {
// NOTE: do not use any imports in this function as it is used standalone in the documents head
// [Joshen] Potentially can remove after full move over to /dashboard
-export const getReturnToPath = (fallback = '/projects') => {
+export const getReturnToPath = (fallback = DEFAULT_HOME) => {
const searchParams = new URLSearchParams(location.search)
// [Joshen] Remove base path value ("/dashboard") from returnTo