The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
ensure other query params are included when there is an existing ?next=
Alaister Youngec9cd56e27b9
diff --git a/studio/hooks/misc/withAuth.tsx b/studio/hooks/misc/withAuth.tsxindex 15776ca1f05..05eb8a0ee9b 100644--- a/studio/hooks/misc/withAuth.tsx+++ b/studio/hooks/misc/withAuth.tsx@@ -2,7 +2,7 @@ import { ComponentType, useEffect } from 'react'import Head from 'next/head'import { NextRouter, useRouter } from 'next/router'-import { STORAGE_KEY } from 'lib/gotrue'+import { getNextPath, STORAGE_KEY } from 'lib/gotrue'import { IS_PLATFORM } from 'lib/constants'import { useProfile, useStore, usePermissions } from 'hooks'import Error500 from '../../pages/500'@@ -86,7 +86,7 @@ export function withAuth<T>(to the login page if they are guaranteed (no token at all) to not be logged in. */}<scriptdangerouslySetInnerHTML={{- __html: `if (!localStorage.getItem('${STORAGE_KEY}') && !location.hash) {location.replace('/sign-in?next=' + (new URLSearchParams(location.search).get('next') || encodeURIComponent(location.pathname + location.search + location.hash)))}`,+ __html: `window._getNextPath = ${getNextPath.toString()};if (!localStorage.getItem('${STORAGE_KEY}') && !location.hash) {location.replace('/sign-in?next=' + window._getNextPath(location.pathname))}`,}}/></Head>diff --git a/studio/lib/gotrue.ts b/studio/lib/gotrue.tsindex a06d1d936bb..8a3feb42cac 100644--- a/studio/lib/gotrue.ts+++ b/studio/lib/gotrue.ts@@ -40,18 +40,13 @@ export const getIdentity = (gotrueUser: User) => {// NOTE: do not use any imports in this function,// as it is use standalone in the documents head-export const getNextPath = () => {- if (typeof window === 'undefined') {- // make sure this method is SSR safe- return '/projects'- }-+export const getNextPath = (fallback = '/projects') => {const searchParams = new URLSearchParams(location.search)const returnTo = searchParams.get('next')searchParams.delete('next')- const next = returnTo ?? '/projects'+ const next = returnTo ?? fallbackconst remainingSearchParams = searchParams.toString()if (next === 'new-project') {