File tree Expand file tree Collapse file tree
apps/builder/app/builder/features/topbar Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,29 +47,42 @@ export const AddDomain = ({
4747 return ;
4848 }
4949
50+ let cname = extractCname ( domain ) ;
5051 // detect provider only when root domain is specified
51- if ( extractCname ( domain ) === "@" ) {
52+ if ( cname === "@" ) {
5253 const registrar = await nativeClient . domain . findDomainRegistrar . query ( {
5354 domain,
5455 } ) ;
5556 // enforce www subdomain when no support for cname flattening
5657 // and root cname can conflict with MX or NS
5758 if ( ! registrar . cnameFlattening ) {
5859 domain = `www.${ domain } ` ;
60+ cname = "www" ;
5961 }
6062 }
6163
6264 const result = await nativeClient . domain . create . mutate ( {
6365 domain,
6466 projectId,
6567 } ) ;
66-
6768 if ( result . success === false ) {
6869 toast . error ( result . error ) ;
6970 setError ( result . error ) ;
7071 return ;
7172 }
7273
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+
7386 onCreate ( domain ) ;
7487
7588 await refresh ( ) ;
Original file line number Diff line number Diff line change @@ -302,6 +302,15 @@ const DomainItem = ({
302302 ttl : 300 ,
303303 } as const ,
304304 ] ;
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+ }
305314
306315 return (
307316 < CollapsibleDomainSection
You can’t perform that action at this time.
0 commit comments