File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
apps/builder/app/builder/features/topbar Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -47,29 +47,42 @@ export const AddDomain = ({
47
47
return ;
48
48
}
49
49
50
+ let cname = extractCname ( domain ) ;
50
51
// detect provider only when root domain is specified
51
- if ( extractCname ( domain ) === "@" ) {
52
+ if ( cname === "@" ) {
52
53
const registrar = await nativeClient . domain . findDomainRegistrar . query ( {
53
54
domain,
54
55
} ) ;
55
56
// enforce www subdomain when no support for cname flattening
56
57
// and root cname can conflict with MX or NS
57
58
if ( ! registrar . cnameFlattening ) {
58
59
domain = `www.${ domain } ` ;
60
+ cname = "www" ;
59
61
}
60
62
}
61
63
62
64
const result = await nativeClient . domain . create . mutate ( {
63
65
domain,
64
66
projectId,
65
67
} ) ;
66
-
67
68
if ( result . success === false ) {
68
69
toast . error ( result . error ) ;
69
70
setError ( result . error ) ;
70
71
return ;
71
72
}
72
73
74
+ if ( cname === "www" ) {
75
+ const result = await nativeClient . domain . create . mutate ( {
76
+ domain : domain . slice ( "www." . length ) ,
77
+ projectId,
78
+ } ) ;
79
+ if ( result . success === false ) {
80
+ toast . error ( result . error ) ;
81
+ setError ( result . error ) ;
82
+ return ;
83
+ }
84
+ }
85
+
73
86
onCreate ( domain ) ;
74
87
75
88
await refresh ( ) ;
Original file line number Diff line number Diff line change @@ -302,6 +302,15 @@ const DomainItem = ({
302
302
ttl : 300 ,
303
303
} as const ,
304
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
+ } ) ;
313
+ }
305
314
306
315
return (
307
316
< CollapsibleDomainSection
You can’t perform that action at this time.
0 commit comments