The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
DRY
Jonathan Summers-Muir361389383337
diff --git a/studio/components/interfaces/SignIn/ForgotPasswordForm.tsx b/studio/components/interfaces/SignIn/ForgotPasswordForm.tsxindex f0a0b1ee79d..e90a6ddb788 100644--- a/studio/components/interfaces/SignIn/ForgotPasswordForm.tsx+++ b/studio/components/interfaces/SignIn/ForgotPasswordForm.tsx@@ -14,7 +14,6 @@ const forgotPasswordSchema = object({const ForgotPasswordForm = () => {const { ui } = useStore()const router = useRouter()- const { basePath } = routerconst [captchaToken, setCaptchaToken] = useState<string | null>(null)const captchaRef = useRef<HCaptcha>(null)@@ -36,7 +35,7 @@ const ForgotPasswordForm = () => {hcaptchaToken: token ?? undefined,redirectTo: `${process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview'- ? process.env.NEXT_PUBLIC_VERCEL_URL + (basePath && `/${basePath}`)+ ? process.env.NEXT_PUBLIC_VERCEL_URL: process.env.NEXT_PUBLIC_SITE_URL}/reset-password`,})diff --git a/studio/components/interfaces/SignIn/SignInSSOForm.tsx b/studio/components/interfaces/SignIn/SignInSSOForm.tsxindex e5211c6e2cb..3c26d2dc1d6 100644--- a/studio/components/interfaces/SignIn/SignInSSOForm.tsx+++ b/studio/components/interfaces/SignIn/SignInSSOForm.tsx@@ -2,7 +2,6 @@ import HCaptcha from '@hcaptcha/react-hcaptcha'import { useQueryClient } from '@tanstack/react-query'import { useStore } from 'hooks'import { auth, getReturnToPath } from 'lib/gotrue'-import { useRouter } from 'next/router'import { useRef, useState } from 'react'import { Button, Form, Input } from 'ui'import { object, string } from 'yup'@@ -13,7 +12,6 @@ const signInSchema = object({const SignInSSOForm = () => {const { ui } = useStore()- const { basePath } = useRouter()const queryClient = useQueryClient()const [captchaToken, setCaptchaToken] = useState<string | null>(null)@@ -37,7 +35,7 @@ const SignInSSOForm = () => {captchaToken: token ?? undefined,redirectTo: `${process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview'- ? process.env.NEXT_PUBLIC_VERCEL_URL + (basePath && `${basePath}`)+ ? process.env.NEXT_PUBLIC_VERCEL_URL: process.env.NEXT_PUBLIC_SITE_URL}${getReturnToPath()}`,},diff --git a/studio/components/interfaces/SignIn/SignInWithGitHub.tsx b/studio/components/interfaces/SignIn/SignInWithGitHub.tsxindex 7e1420574f1..f4e1f1549b6 100644--- a/studio/components/interfaces/SignIn/SignInWithGitHub.tsx+++ b/studio/components/interfaces/SignIn/SignInWithGitHub.tsx@@ -1,9 +1,7 @@import { auth, getReturnToPath } from 'lib/gotrue'-import { useRouter } from 'next/router'import { Button, IconGitHub } from 'ui'const SignInWithGitHub = () => {- const { basePath } = useRouter()async function handleGithubSignIn() {try {const { error } = await auth.signInWithOAuth({@@ -11,7 +9,7 @@ const SignInWithGitHub = () => {options: {redirectTo: `${process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview'- ? process.env.NEXT_PUBLIC_VERCEL_URL + (basePath && `${basePath}`)+ ? process.env.NEXT_PUBLIC_VERCEL_URL: process.env.NEXT_PUBLIC_SITE_URL}${getReturnToPath()}`,},diff --git a/studio/components/interfaces/SignIn/SignUpForm.tsx b/studio/components/interfaces/SignIn/SignUpForm.tsxindex 50d2e806abe..a506f8eda27 100644--- a/studio/components/interfaces/SignIn/SignUpForm.tsx+++ b/studio/components/interfaces/SignIn/SignUpForm.tsx@@ -8,7 +8,6 @@ import { post } from 'lib/common/fetch'import { API_URL } from 'lib/constants'import { passwordSchema } from 'lib/schemas'import PasswordConditionsHelper from './PasswordConditionsHelper'-import { useRouter } from 'next/router'const signUpSchema = passwordSchema.shape({email: yup.string().email().required().label('Email'),@@ -16,7 +15,6 @@ const signUpSchema = passwordSchema.shape({const SignUpForm = () => {const { ui } = useStore()- const { basePath } = useRouter()const captchaRef = useRef<HCaptcha>(null)const [showConditions, setShowConditions] = useState(false)const [isSubmitted, setIsSubmitted] = useState(false)@@ -41,7 +39,7 @@ const SignUpForm = () => {hcaptchaToken: token ?? null,redirectTo: `${process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview'- ? process.env.NEXT_PUBLIC_VERCEL_URL + (basePath && `${basePath}`)+ ? process.env.NEXT_PUBLIC_VERCEL_URL: process.env.NEXT_PUBLIC_SITE_URL}/sign-in`,})diff --git a/studio/lib/gotrue.ts b/studio/lib/gotrue.tsindex 3e6d7f258f6..7cb3de31f7c 100644--- a/studio/lib/gotrue.ts+++ b/studio/lib/gotrue.ts@@ -1,4 +1,5 @@import { GoTrueClient, User } from '@supabase/gotrue-js'+import { useRouter } from 'next/router'export const STORAGE_KEY = process.env.NEXT_PUBLIC_STORAGE_KEY || 'supabase.dashboard.auth.token'@@ -41,6 +42,7 @@ export const getIdentity = (gotrueUser: User) => {// NOTE: do not use any imports in this function,// as it is used standalone in the documents headexport const getReturnToPath = (fallback = '/projects') => {+ const { basePath } = useRouter()const searchParams = new URLSearchParams(location.search)let returnTo = searchParams.get('returnTo') ?? fallback@@ -48,5 +50,5 @@ export const getReturnToPath = (fallback = '/projects') => {const remainingSearchParams = searchParams.toString()- return returnTo + (remainingSearchParams ? `?${remainingSearchParams}` : '')+ return basePath + returnTo + (remainingSearchParams ? `?${remainingSearchParams}` : '')}