Skip to content

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

adds fallback for undefined base path in location.replace

Alaister Younge5c25500e093
diff --git a/studio/components/layouts/SignInLayout/SignInLayout.tsx b/studio/components/layouts/SignInLayout/SignInLayout.tsx
index d998f4ff4c9..6c8e77de0d9 100644
--- a/studio/components/layouts/SignInLayout/SignInLayout.tsx
+++ b/studio/components/layouts/SignInLayout/SignInLayout.tsx
@@ -80,7 +80,9 @@ const SignInLayout = ({
<Head>
<script
dangerouslySetInnerHTML={{
- __html: `window._getReturnToPath = ${getReturnToPath.toString()};if (localStorage.getItem('${STORAGE_KEY}') && !(new URLSearchParams(location.search).has('next'))) {location.replace('${BASE_PATH}' + window._getReturnToPath())}`,
+ __html: `window._getReturnToPath = ${getReturnToPath.toString()};if (localStorage.getItem('${STORAGE_KEY}') && !(new URLSearchParams(location.search).has('next'))) {location.replace('${
+ BASE_PATH ?? ''
+ }' + window._getReturnToPath())}`,
}}
/>
</Head>
diff --git a/studio/hooks/misc/withAuth.tsx b/studio/hooks/misc/withAuth.tsx
index 6d4a54a0e01..e2c0ddcc643 100644
--- a/studio/hooks/misc/withAuth.tsx
+++ b/studio/hooks/misc/withAuth.tsx
@@ -88,7 +88,9 @@ export function withAuth<T>(
{IS_PLATFORM && (
<script
dangerouslySetInnerHTML={{
- __html: `window._getReturnToPath = ${getReturnToPath.toString()};if (!localStorage.getItem('${STORAGE_KEY}') && !location.hash) {const searchParams = new URLSearchParams(location.search);searchParams.set('returnTo', location.pathname);location.replace('${basePath}/sign-in' + '?' + searchParams.toString())}`,
+ __html: `window._getReturnToPath = ${getReturnToPath.toString()};if (!localStorage.getItem('${STORAGE_KEY}') && !location.hash) {const searchParams = new URLSearchParams(location.search);searchParams.set('returnTo', location.pathname);location.replace('${
+ basePath ?? ''
+ }/sign-in' + '?' + searchParams.toString())}`,
}}
/>
)}