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

This commit is contained in:
Julian Domke authored and GitHub committed 2026-09-23 09:44:04 +02:00
1 parent e5685126b8
commit 3ec2dfca44
3 files changed
+24 -1

No files matched your search

@@ -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() } }))
@@ -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 =
@@ -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>