@@ -282,6 +282,11 @@ func reportNextStepCert(ctx context.Context, hostname string, cert *fly.AppCerti
282282 return err
283283 }
284284
285+ cnameTarget , err := apiClient .GetAppCNAMETarget (ctx , appName )
286+ if err != nil {
287+ return err
288+ }
289+
285290 var ipV4 fly.IPAddress
286291 var ipV6 fly.IPAddress
287292 var configuredipV4 bool
@@ -354,6 +359,7 @@ func reportNextStepCert(ctx context.Context, hostname string, cert *fly.AppCerti
354359 Certificate : cert ,
355360 IPv4Address : ipV4 ,
356361 IPv6Address : ipV6 ,
362+ CNAMETarget : cnameTarget ,
357363 ExternalProxyDetected : externalProxyHint ,
358364 })
359365 } else {
@@ -373,6 +379,7 @@ func reportNextStepCert(ctx context.Context, hostname string, cert *fly.AppCerti
373379 Certificate : cert ,
374380 IPv4Address : ipV4 ,
375381 IPv6Address : ipV6 ,
382+ CNAMETarget : cnameTarget ,
376383 ExternalProxyDetected : externalProxyHint ,
377384 })
378385 }
@@ -388,6 +395,7 @@ func reportNextStepCert(ctx context.Context, hostname string, cert *fly.AppCerti
388395 Certificate : cert ,
389396 IPv4Address : ipV4 ,
390397 IPv6Address : ipV6 ,
398+ CNAMETarget : cnameTarget ,
391399 ExternalProxyDetected : externalProxyHint ,
392400 })
393401 } else {
@@ -426,13 +434,13 @@ type DNSSetupFlags struct {
426434 Certificate * fly.AppCertificate
427435 IPv4Address fly.IPAddress
428436 IPv6Address fly.IPAddress
437+ CNAMETarget string
429438 ExternalProxyDetected bool
430439}
431440
432441func printDNSSetupOptions (opts DNSSetupFlags ) error {
433442 io := iostreams .FromContext (opts .Context )
434443 colorize := io .ColorScheme ()
435- appName := appconfig .NameFromContext (opts .Context )
436444 hasIPv4 := opts .IPv4Address .Address != ""
437445 hasIPv6 := opts .IPv6Address .Address != ""
438446 promoteExtProxy := opts .ExternalProxyDetected && ! opts .Certificate .IsWildcard
@@ -491,9 +499,9 @@ func printDNSSetupOptions(opts DNSSetupFlags) error {
491499 fmt .Fprintln (io .Out )
492500 optionNum ++
493501
494- if ! opts .Certificate .IsApex && (hasIPv4 || hasIPv6 ) {
502+ if ! opts .Certificate .IsApex && (hasIPv4 || hasIPv6 ) && opts . CNAMETarget != "" {
495503 fmt .Fprintf (io .Out , colorize .Cyan ("%d. CNAME record\n \n " ), optionNum )
496- fmt .Fprintf (io .Out , " CNAME %s → %s.fly.dev \n " , getRecordName (opts .Hostname ), appName )
504+ fmt .Fprintf (io .Out , " CNAME %s → %s\n " , getRecordName (opts .Hostname ), opts . CNAMETarget )
497505 fmt .Fprintln (io .Out )
498506 optionNum ++
499507 }
0 commit comments