From 3ec2dfca44c34335e9c5e24adb9cbedaca9edb84 Mon Sep 17 00:00:00 2001 From: Julian Domke <68325451+juleswritescode@users.noreply.github.com> Date: Wed, 23 Sep 2026 09:44:04 +0200 Subject: [PATCH] fix(stripe-atlas): guard stripe-atlas page in self-hosted mode (#50780) --- .../StripeAtlasApplication.test.tsx | 5 +++++ .../stripe-atlas-application-query.ts | 3 ++- apps/studio/pages/stripe-atlas-application.tsx | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) 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()), + 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 ( <>