Skip to content

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

fix: added route exemption to router validator

Jonathan Summers-Muirb01e1757b6bb
diff --git a/studio/components/interfaces/App/RouteValidationWrapper.tsx b/studio/components/interfaces/App/RouteValidationWrapper.tsx
index 5dbc8420ccc..c2b2059c356 100644
--- a/studio/components/interfaces/App/RouteValidationWrapper.tsx
+++ b/studio/components/interfaces/App/RouteValidationWrapper.tsx
@@ -15,7 +15,31 @@ const RouteValidationWrapper: FC = ({ children }) => {
const projectRef = router.query.ref
const orgSlug = router.query.slug
+ /**
+ * Array of urls/routes that should be ignored
+ */
+ const excemptUrls: string[] = [
+ // project creation route, allows the page to self determine it's own route, it will redirect to the first org
+ // or prompt the user to create an organaization
+ // this is used by database.dev, usually as /new/new-project
+ '/new/[slug]',
+ ]
+
+ /**
+ * Map through all the urls that are excluded
+ * from route validation check
+ *
+ * @returns a boolean
+ */
+ function isExceptUrl() {
+ const found = excemptUrls.includes(router?.pathname)
+ return found
+ }
+
useEffect(() => {
+ // check if current route is excempted from route validation check
+ if (isExceptUrl()) return
+
if (orgsInitialized && orgSlug) {
// Check validity of organization that user is trying to access
const organizations = app.organizations.list()
@@ -31,6 +55,9 @@ const RouteValidationWrapper: FC = ({ children }) => {
}, [orgsInitialized])
useEffect(() => {
+ // check if current route is excempted from route validation check
+ if (isExceptUrl()) return
+
if (projectsInitialized && projectRef) {
// Check validity of project that the user is trying to access
const projects = app.projects.list()