Skip to content

Commit 399000a

Browse files
committed
Put root first
1 parent 9f9f0fd commit 399000a

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

apps/builder/app/builder/features/topbar/domains.tsx

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
useState,
3030
type ReactNode,
3131
} from "react";
32-
import { Entri } from "./entri";
32+
import { Entri, type DnsRecord } from "./entri";
3333
import { nativeClient } from "~/shared/trpc/trpc-client";
3434
import { useStore } from "@nanostores/react";
3535
import { $publisherHost } from "~/shared/nano-states";
@@ -288,28 +288,32 @@ const DomainItem = ({
288288

289289
const publisherHost = useStore($publisherHost);
290290
const cname = extractCname(projectDomain.domain);
291-
const dnsRecords = [
292-
{
293-
type: "CNAME",
294-
host: cname,
295-
value: `${projectDomain.cname}.customers.${publisherHost}`,
296-
ttl: 300,
297-
} as const,
298-
{
299-
type: "TXT",
300-
host: cname === "@" ? "_webstudio_is" : `_webstudio_is.${cname}`,
301-
value: projectDomain.expectedTxtRecord,
302-
ttl: 300,
303-
} as const,
304-
];
305-
// add both www and root cname to support root -> www redirect
306-
if (cname === "www") {
307-
dnsRecords.push({
308-
type: "TXT",
309-
host: "_webstudio_is",
310-
value: projectDomain.expectedTxtRecord,
311-
ttl: 300,
312-
});
291+
const cnameRecord: DnsRecord = {
292+
type: "CNAME",
293+
host: cname,
294+
value: `${projectDomain.cname}.customers.${publisherHost}`,
295+
ttl: 300,
296+
};
297+
const rootTxtRecord: DnsRecord = {
298+
type: "TXT",
299+
host: "_webstudio_is",
300+
value: projectDomain.expectedTxtRecord,
301+
ttl: 300,
302+
};
303+
const subdomainTxtRecord: DnsRecord = {
304+
type: "TXT",
305+
host: `_webstudio_is.${cname}`,
306+
value: projectDomain.expectedTxtRecord,
307+
ttl: 300,
308+
};
309+
const dnsRecords: DnsRecord[] = [cnameRecord];
310+
if (cname === "@") {
311+
dnsRecords.push(rootTxtRecord);
312+
} else if (cname === "www") {
313+
// add both www and root cname to support root -> www redirect
314+
dnsRecords.push(rootTxtRecord, subdomainTxtRecord);
315+
} else {
316+
dnsRecords.push(subdomainTxtRecord);
313317
}
314318

315319
return (

apps/builder/app/builder/features/topbar/entri.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { $userPlanFeatures } from "~/shared/nano-states";
77
import { extractCname } from "./cname";
88

99
// https://developers.entri.com/docs/install
10-
type DnsRecord = {
10+
export type DnsRecord = {
1111
type: "CNAME" | "ALIAS" | "TXT";
1212
host: string;
1313
value: string;

0 commit comments

Comments
 (0)