Skip to content

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

fix(stripe-atlas): guard stripe-atlas page in self-hosted mode (#50780)

Julian Domke3ec2dfca44c3
diff --git a/apps/studio/components/interfaces/StripeAtlasApplication/StripeAtlasApplication.test.tsx b/apps/studio/components/interfaces/StripeAtlasApplication/StripeAtlasApplication.test.tsx
index 284b33ca60a..320ae6c3de5 100644
--- a/apps/studio/components/interfaces/StripeAtlasApplication/StripeAtlasApplication.test.tsx
+++ b/apps/studio/components/interfaces/StripeAtlasApplication/StripeAtlasApplication.test.tsx
@@ -9,6 +9,11 @@ import { StripeAtlasApplicationScreen } from './StripeAtlasApplication'
import { customRender } from '@/tests/lib/custom-render'
import { addAPIMock, type APIErrorBody } from '@/tests/lib/msw'
+vi.mock('@/lib/constants', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/lib/constants')>()),
+ IS_PLATFORM: true,
+}))
+
type PerkApplication = platformComponents['schemas']['PerkApplicationDataResponse_Output']
vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn() } }))
diff --git a/apps/studio/data/stripe-atlas/stripe-atlas-application-query.ts b/apps/studio/data/stripe-atlas/stripe-atlas-application-query.ts
index 895da54ef3a..a73ff45baf4 100644
--- a/apps/studio/data/stripe-atlas/stripe-atlas-application-query.ts
+++ b/apps/studio/data/stripe-atlas/stripe-atlas-application-query.ts
@@ -4,6 +4,7 @@ import { toast } from 'sonner'
import { stripeAtlasKeys } from './keys'
import { handleError, post } from '@/data/fetchers'
+import { IS_PLATFORM } from '@/lib/constants'
import type { ResponseError, UseCustomMutationOptions } from '@/types'
export type StripeAtlasApplicationVariables = {
@@ -38,7 +39,7 @@ export const stripeAtlasApplicationQueryOptions = ({
queryOptions({
queryKey: stripeAtlasKeys.application(stripeAtlasToken),
queryFn: ({ signal }) => getStripeAtlasApplication({ stripeAtlasToken }, signal),
- enabled: typeof stripeAtlasToken !== 'undefined',
+ enabled: IS_PLATFORM && typeof stripeAtlasToken !== 'undefined',
})
export type CompleteStripeAtlasApplicationVariables =
diff --git a/apps/studio/pages/stripe-atlas-application.tsx b/apps/studio/pages/stripe-atlas-application.tsx
index 7c820b94e1b..eebf8c1f255 100644
--- a/apps/studio/pages/stripe-atlas-application.tsx
+++ b/apps/studio/pages/stripe-atlas-application.tsx
@@ -1,6 +1,9 @@
import Head from 'next/head'
+import { useRouter } from 'next/router'
+import { useEffect } from 'react'
import { StripeAtlasApplicationScreen } from '@/components/interfaces/StripeAtlasApplication/StripeAtlasApplication'
+import { IS_PLATFORM } from '@/lib/constants'
import { buildStudioPageTitle } from '@/lib/page-title'
import type { NextPageWithLayout } from '@/types'
@@ -10,8 +13,22 @@ const PAGE_TITLE = buildStudioPageTitle({ section: 'Stripe Atlas Application', b
* Page needs to be pre-auth – customers will be redirected here from the
* Stripe Atlas dashboard, either directly via a static link or via a callbackURL from the mgmt API.
* The user's auth state doesn't matter for the application; what matters is the the query params of the callbackURL.
+ *
+ * Only available on the hosted platform – self-hosted Studio routes to 404.
*/
const StripeAtlasApplicationPage: NextPageWithLayout = () => {
+ const router = useRouter()
+
+ useEffect(() => {
+ if (!IS_PLATFORM) {
+ router.replace('/404')
+ }
+ }, [router])
+
+ if (!IS_PLATFORM) {
+ return null
+ }
+
return (
<>
<Head>