Browse Source

add displaying cname record on the domain settings section

Pouria Ezzati 1 year ago
parent
commit
0fc37b36ab

+ 1 - 0
.example.env

@@ -46,6 +46,7 @@ DISALLOW_ANONYMOUS_LINKS=true
 # Optional - This would be shown to the user on the settings page
 # It's only for display purposes and has no other use
 SERVER_IP_ADDRESS=
+SERVER_CNAME_ADDRESS=
 
 # Optional - Use HTTPS for links with custom domain
 # It's on you to generate SSL certificates for those domains manually, at least on this version for now

+ 1 - 0
server/env.js

@@ -33,6 +33,7 @@ const env = cleanEnv(process.env, {
   DISALLOW_ANONYMOUS_LINKS: bool({ default: true }),
   DISALLOW_REGISTRATION: bool({ default: true }),
   SERVER_IP_ADDRESS: str({ default: "" }),
+  SERVER_CNAME_ADDRESS: str({ default: "" }),
   CUSTOM_DOMAIN_USE_HTTPS: bool({ default: false }),
   JWT_SECRET: str({ devDefault: "securekey" }),
   MAIL_ENABLED: bool({ default: false }),

+ 1 - 0
server/handlers/locals.handler.js

@@ -25,6 +25,7 @@ function config(req, res, next) {
   res.locals.site_name = env.SITE_NAME;
   res.locals.contact_email = env.CONTACT_EMAIL;
   res.locals.server_ip_address = env.SERVER_IP_ADDRESS;
+  res.locals.server_cname_address = env.SERVER_CNAME_ADDRESS;
   res.locals.disallow_registration = env.DISALLOW_REGISTRATION;
   res.locals.mail_enabled = env.MAIL_ENABLED;
   res.locals.report_email = env.REPORT_EMAIL;

+ 23 - 9
server/views/partials/settings/domain/index.hbs

@@ -7,15 +7,29 @@
   <b>yoursite.com/shorturl.</b>
 </p>
 
-<p>
-  Point your domain's A record to 
-  {{#if server_ip_address}}
-    <b>{{server_ip_address}}</b>
-  {{else}}
-    our <b>IP address</b>
-  {{/if}} 
-  then add the domain via the form below:
-</p>
+{{#if server_cname_address}}
+  <p>
+    Point your domain's A record to 
+    {{#if server_ip_address}}
+      <b>{{server_ip_address}}</b>
+    {{else}}
+      our <b>IP address</b>
+    {{/if}} or your subdomain's CNAME record to
+    <b>{{server_cname_address}}</b>. If you're using <b>Cloudflare</b>,
+    make sure to use <b>DNS only</b> mode for your subdomain.
+  </p>
+  <p>Then, add the domain via the form below:</p>
+{{else}}
+  <p>
+    Point your domain's A record to 
+    {{#if server_ip_address}}
+      <b>{{server_ip_address}}</b>
+    {{else}}
+      our <b>IP address</b>
+    {{/if}} 
+    then add the domain via the form below:
+  </p>
+{{/if}}
 
 {{> settings/domain/table}}
 <div class="add-domain-wrapper">