diff --git a/apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/domains/page-client.tsx b/apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/domains/page-client.tsx index 13644d392..4b4f956ab 100644 --- a/apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/domains/page-client.tsx +++ b/apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/domains/page-client.tsx @@ -4,6 +4,7 @@ import { InputField, SwitchField } from "@/components/form-fields"; import { SettingCard, SettingSwitch } from "@/components/settings"; import { AdminDomainConfig, AdminProject } from "@stackframe/stack"; import { urlSchema } from "@stackframe/stack-shared/dist/schema-fields"; +import { isValidUrl } from "@stackframe/stack-shared/dist/utils/urls"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionCell, ActionDialog, Alert, Button, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Typography } from "@stackframe/stack-ui"; import React from "react"; import * as yup from "yup"; @@ -104,10 +105,11 @@ function EditDialog(props: { /> {props.type === 'create' && - urlSchema.url().defined().isValidSync('https://' + form.watch('domain')) && - !((form.watch('domain') as any)?.startsWith('www.')) && ( + isValidUrl('https://' + form.watch('domain')) && + !((form.watch('domain') as any)?.startsWith('www.')) && + isValidUrl('https://www.' + form.watch('domain')) && ( diff --git a/packages/stack-shared/src/helpers/production-mode.ts b/packages/stack-shared/src/helpers/production-mode.ts index c42284566..35f8393fb 100644 --- a/packages/stack-shared/src/helpers/production-mode.ts +++ b/packages/stack-shared/src/helpers/production-mode.ts @@ -1,5 +1,5 @@ import { ProjectsCrud } from "../interface/crud/projects"; -import { StackAssertionError } from "../utils/errors"; +import { StackAssertionError, captureError } from "../utils/errors"; import { isLocalhost } from "../utils/urls"; export type ProductionModeError = { @@ -23,10 +23,15 @@ export function getProductionModeErrors(project: ProjectsCrud["Admin"]["Read"]): try { url = new URL(domain); } catch (e) { - throw new StackAssertionError("Domain was somehow not a valid URL; we should've caught this when setting the domain in the first place", { + captureError("production-mode-domain-not-valid", new StackAssertionError("Domain was somehow not a valid URL; we should've caught this when setting the domain in the first place", { domain, projectId: project + })); + errors.push({ + message: "Trusted domain is not a valid URL: " + domain, + relativeFixUrl: domainsFixUrl, }); + continue; } if (isLocalhost(url)) {