Skip to content

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

chore: updates page banning logic

gitstartec50e28c927b
diff --git a/studio/hooks/misc/withAuth.tsx b/studio/hooks/misc/withAuth.tsx
index bd0bfc2e287..4ce144da02b 100644
--- a/studio/hooks/misc/withAuth.tsx
+++ b/studio/hooks/misc/withAuth.tsx
@@ -8,7 +8,13 @@ import { useProfile, useStore, usePermissions } from 'hooks'
import Error500 from '../../pages/500'
import { NextPageWithLayout } from 'types'
-const PLATFORM_ONLY_PAGES = ['reports', 'settings']
+const PLATFORM_ONLY_PAGES = [
+ 'reports',
+ 'settings',
+ 'auth/providers',
+ 'auth/templates',
+ 'auth/url-configuration',
+]
export function withAuth<T>(
WrappedComponent: ComponentType<T> | NextPageWithLayout<T, T>,
@@ -23,7 +29,7 @@ export function withAuth<T>(
const { ref, slug } = router.query
const { app, ui } = rootStore
- const page = router.pathname.split('/')[3]
+ const page = router.pathname.split('/').slice(3).join('/')
const redirectTo = options?.redirectTo ?? defaultRedirectTo(ref)
const redirectIfFound = options?.redirectIfFound
@@ -37,7 +43,9 @@ export function withAuth<T>(
mutate: mutatePermissions,
} = usePermissions(profile, returning)
- const isAccessingBlockedPage = !IS_PLATFORM && PLATFORM_ONLY_PAGES.includes(page)
+ const isAccessingBlockedPage =
+ !IS_PLATFORM &&
+ PLATFORM_ONLY_PAGES.some((platformOnlyPage) => page.startsWith(platformOnlyPage))
const isRedirecting =
isAccessingBlockedPage ||
checkRedirectTo(isLoading, router, profile, error, redirectTo, redirectIfFound)
diff --git a/studio/next.config.js b/studio/next.config.js
index fa3c8265c0a..0684e797af3 100644
--- a/studio/next.config.js
+++ b/studio/next.config.js
@@ -12,132 +12,105 @@ const withTM = require('next-transpile-modules')(['ui', 'common'])
// https://nextjs.org/docs/api-reference/next.config.js/introduction
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
-const IS_PLATFORM = process.env.NEXT_PUBLIC_IS_PLATFORM === 'true'
-
-// Fixes the issue with the user having direct URL access to these pages in non-platform environments,
-// by redirecting to the respective available page.
-const nonPlatformRedirects = [
- {
- source: '/project/:ref/auth/providers',
- destination: '/project/:ref/auth/users',
- permanent: false,
- },
- {
- source: '/project/:ref/auth/templates',
- destination: '/project/:ref/auth/users',
- permanent: false,
- },
- {
- source: '/project/:ref/auth/url-configuration',
- destination: '/project/:ref/auth/users',
- permanent: false,
- },
-]
-
-const generalRedirects = [
- {
- source: '/',
- destination: '/sign-in',
- permanent: false,
- },
- {
- source: '/register',
- destination: '/sign-up',
- permanent: false,
- },
- {
- source: '/signup',
- destination: '/sign-up',
- permanent: false,
- },
- {
- source: '/signin',
- destination: '/sign-in',
- permanent: false,
- },
- {
- source: '/login',
- destination: '/sign-in',
- permanent: false,
- },
- {
- source: '/log-in',
- destination: '/sign-in',
- permanent: false,
- },
- {
- source: '/project/:ref/auth',
- destination: '/project/:ref/auth/users',
- permanent: true,
- },
- {
- source: '/project/:ref/database',
- destination: '/project/:ref/database/tables',
- permanent: true,
- },
- {
- source: '/project/:ref/storage',
- destination: '/project/:ref/storage/buckets',
- permanent: true,
- },
- {
- source: '/project/:ref/settings',
- destination: '/project/:ref/settings/general',
- permanent: true,
- },
- {
- source: '/project/:ref/auth/settings',
- destination: '/project/:ref/auth/users',
- permanent: true,
- },
- {
- source: '/project/:ref/settings/billing',
- destination: '/project/:ref/settings/billing/subscription',
- permanent: true,
- },
- {
- source: '/project/:ref/database/postgres-logs',
- destination: '/project/:ref/logs/postgres-logs',
- permanent: true,
- },
- {
- source: '/project/:ref/database/postgrest-logs',
- destination: '/project/:ref/logs/postgrest-logs',
- permanent: true,
- },
- {
- source: '/project/:ref/database/pgbouncer-logs',
- destination: '/project/:ref/logs/pgbouncer-logs',
- permanent: true,
- },
- {
- source: '/project/:ref/database/realtime-logs',
- destination: '/project/:ref/logs/realtime-logs',
- permanent: true,
- },
- {
- source: '/project/:ref/storage/logs',
- destination: '/project/:ref/logs/storage-logs',
- permanent: true,
- },
- {
- source: '/project/:ref/auth/logs',
- destination: '/project/:ref/logs/auth-logs',
- permanent: true,
- },
- {
- source: '/project/:ref/logs-explorer',
- destination: '/project/:ref/logs/explorer',
- permanent: true,
- },
-]
-
const nextConfig = {
async redirects() {
- if (!IS_PLATFORM) {
- return [...nonPlatformRedirects, ...generalRedirects]
- }
- return generalRedirects
+ return [
+ {
+ source: '/',
+ destination: '/sign-in',
+ permanent: false,
+ },
+ {
+ source: '/register',
+ destination: '/sign-up',
+ permanent: false,
+ },
+ {
+ source: '/signup',
+ destination: '/sign-up',
+ permanent: false,
+ },
+ {
+ source: '/signin',
+ destination: '/sign-in',
+ permanent: false,
+ },
+ {
+ source: '/login',
+ destination: '/sign-in',
+ permanent: false,
+ },
+ {
+ source: '/log-in',
+ destination: '/sign-in',
+ permanent: false,
+ },
+ {
+ source: '/project/:ref/auth',
+ destination: '/project/:ref/auth/users',
+ permanent: true,
+ },
+ {
+ source: '/project/:ref/database',
+ destination: '/project/:ref/database/tables',
+ permanent: true,
+ },
+ {
+ source: '/project/:ref/storage',
+ destination: '/project/:ref/storage/buckets',
+ permanent: true,
+ },
+ {
+ source: '/project/:ref/settings',
+ destination: '/project/:ref/settings/general',
+ permanent: true,
+ },
+ {
+ source: '/project/:ref/auth/settings',
+ destination: '/project/:ref/auth/users',
+ permanent: true,
+ },
+ {
+ source: '/project/:ref/settings/billing',
+ destination: '/project/:ref/settings/billing/subscription',
+ permanent: true,
+ },
+ {
+ source: '/project/:ref/database/postgres-logs',
+ destination: '/project/:ref/logs/postgres-logs',
+ permanent: true,
+ },
+ {
+ source: '/project/:ref/database/postgrest-logs',
+ destination: '/project/:ref/logs/postgrest-logs',
+ permanent: true,
+ },
+ {
+ source: '/project/:ref/database/pgbouncer-logs',
+ destination: '/project/:ref/logs/pgbouncer-logs',
+ permanent: true,
+ },
+ {
+ source: '/project/:ref/database/realtime-logs',
+ destination: '/project/:ref/logs/realtime-logs',
+ permanent: true,
+ },
+ {
+ source: '/project/:ref/storage/logs',
+ destination: '/project/:ref/logs/storage-logs',
+ permanent: true,
+ },
+ {
+ source: '/project/:ref/auth/logs',
+ destination: '/project/:ref/logs/auth-logs',
+ permanent: true,
+ },
+ {
+ source: '/project/:ref/logs-explorer',
+ destination: '/project/:ref/logs/explorer',
+ permanent: true,
+ },
+ ]
},
async headers() {
return [
@@ -189,6 +162,7 @@ const sentryWebpackPluginOptions = {
// Make sure adding Sentry options is the last code to run before exporting, to
// ensure that your source maps include changes from all other Webpack plugins
-module.exports = IS_PLATFORM
- ? withSentryConfig(moduleExports, sentryWebpackPluginOptions)
- : withPlugins([withTM()], nextConfig)
+module.exports =
+ process.env.NEXT_PUBLIC_IS_PLATFORM === 'true'
+ ? withSentryConfig(moduleExports, sentryWebpackPluginOptions)
+ : withPlugins([withTM()], nextConfig)