Skip to content

Commit b8a7e91

Browse files
committed
Fix "Domain was somehow not a valid URL"
1 parent 5cfc65c commit b8a7e91

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/domains/page-client.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { InputField, SwitchField } from "@/components/form-fields";
44
import { SettingCard, SettingSwitch } from "@/components/settings";
55
import { AdminDomainConfig, AdminProject } from "@stackframe/stack";
66
import { urlSchema } from "@stackframe/stack-shared/dist/schema-fields";
7+
import { isValidUrl } from "@stackframe/stack-shared/dist/utils/urls";
78
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionCell, ActionDialog, Alert, Button, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Typography } from "@stackframe/stack-ui";
89
import React from "react";
910
import * as yup from "yup";
@@ -104,10 +105,11 @@ function EditDialog(props: {
104105
/>
105106

106107
{props.type === 'create' &&
107-
urlSchema.url().defined().isValidSync('https://' + form.watch('domain')) &&
108-
!((form.watch('domain') as any)?.startsWith('www.')) && (
108+
isValidUrl('https://' + form.watch('domain')) &&
109+
!((form.watch('domain') as any)?.startsWith('www.')) &&
110+
isValidUrl('https://www.' + form.watch('domain')) && (
109111
<SwitchField
110-
label={`Also add www.${form.watch('domain') as any ?? ''} to the trusted domains`}
112+
label={`Also add www.${form.watch('domain') as any ?? ''} as a trusted domain`}
111113
name="addWww"
112114
control={form.control}
113115
/>

packages/stack-shared/src/helpers/production-mode.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ProjectsCrud } from "../interface/crud/projects";
2-
import { StackAssertionError } from "../utils/errors";
2+
import { StackAssertionError, captureError } from "../utils/errors";
33
import { isLocalhost } from "../utils/urls";
44

55
export type ProductionModeError = {
@@ -23,10 +23,15 @@ export function getProductionModeErrors(project: ProjectsCrud["Admin"]["Read"]):
2323
try {
2424
url = new URL(domain);
2525
} catch (e) {
26-
throw new StackAssertionError("Domain was somehow not a valid URL; we should've caught this when setting the domain in the first place", {
26+
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", {
2727
domain,
2828
projectId: project
29+
}));
30+
errors.push({
31+
message: "Trusted domain is not a valid URL: " + domain,
32+
relativeFixUrl: domainsFixUrl,
2933
});
34+
continue;
3035
}
3136

3237
if (isLocalhost(url)) {

0 commit comments

Comments
 (0)