From 393f5f27ed3042f84fa26faea21e886219e5e901 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Sat, 21 Jan 2023 18:20:10 +0100 Subject: [PATCH] :children_crossing: (share) Hide custom domain dropdown when env isn't configured Related to #269 --- .../src/features/publish/components/SharePage.tsx | 5 +++-- apps/builder/src/pages/api/customDomains.ts | 2 +- apps/builder/src/pages/api/customDomains/[domain].ts | 2 +- apps/docs/docs/self-hosting/configuration/builder.mdx | 10 +++++----- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/builder/src/features/publish/components/SharePage.tsx b/apps/builder/src/features/publish/components/SharePage.tsx index d14b94af4..78dc832a4 100644 --- a/apps/builder/src/features/publish/components/SharePage.tsx +++ b/apps/builder/src/features/publish/components/SharePage.tsx @@ -21,7 +21,7 @@ import { Text, } from '@chakra-ui/react' import { Plan } from 'db' -import { isDefined, getViewerUrl, isNotDefined } from 'utils' +import { isDefined, getViewerUrl, isNotDefined, env } from 'utils' import { isPublicDomainAvailableQuery } from '../queries/isPublicDomainAvailableQuery' import { parseDefaultPublicId } from '../utils' import { EditableUrl } from './EditableUrl' @@ -122,7 +122,8 @@ export const SharePage = () => { /> )} - {isNotDefined(typebot?.customDomain) ? ( + {isNotDefined(typebot?.customDomain) && + env('VERCEL_VIEWER_PROJECT_NAME') ? ( <> {isProPlan(workspace) ? ( { const createDomainOnVercel = (name: string) => got.post({ - url: `https://api.vercel.com/v8/projects/${process.env.VERCEL_VIEWER_PROJECT_NAME}/domains?teamId=${process.env.VERCEL_TEAM_ID}`, + url: `https://api.vercel.com/v8/projects/${process.env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME}/domains?teamId=${process.env.VERCEL_TEAM_ID}`, headers: { Authorization: `Bearer ${process.env.VERCEL_TOKEN}` }, json: { name }, }) diff --git a/apps/builder/src/pages/api/customDomains/[domain].ts b/apps/builder/src/pages/api/customDomains/[domain].ts index 244c01510..6942d0d76 100644 --- a/apps/builder/src/pages/api/customDomains/[domain].ts +++ b/apps/builder/src/pages/api/customDomains/[domain].ts @@ -27,7 +27,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { const deleteDomainOnVercel = (name: string) => got.delete({ - url: `https://api.vercel.com/v8/projects/${process.env.VERCEL_VIEWER_PROJECT_NAME}/domains/${name}?teamId=${process.env.VERCEL_TEAM_ID}`, + url: `https://api.vercel.com/v8/projects/${process.env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME}/domains/${name}?teamId=${process.env.VERCEL_TEAM_ID}`, headers: { Authorization: `Bearer ${process.env.VERCEL_TOKEN}` }, }) diff --git a/apps/docs/docs/self-hosting/configuration/builder.mdx b/apps/docs/docs/self-hosting/configuration/builder.mdx index c984939b4..73f4d2f67 100644 --- a/apps/docs/docs/self-hosting/configuration/builder.mdx +++ b/apps/docs/docs/self-hosting/configuration/builder.mdx @@ -214,11 +214,11 @@ These can also be added to the `viewer` environment

Vercel (custom domains)

-| Parameter | Default | Description | -| -------------------------- | ------- | ----------------------------------------------- | -| VERCEL_TOKEN | | Vercel API token | -| VERCEL_VIEWER_PROJECT_NAME | | The name of the viewer project in Vercel | -| VERCEL_TEAM_ID | | Vercel team ID that contains the viewer project | +| Parameter | Default | Description | +| -------------------------------------- | ------- | ----------------------------------------------- | +| VERCEL_TOKEN | | Vercel API token | +| NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME | | The name of the viewer project in Vercel | +| VERCEL_TEAM_ID | | Vercel team ID that contains the viewer project |