When deploying a project to now you'll always get a unique subdomain provisioned for your deployment. This makes it very easy to iterate on code and share the changes made with other people quickly.
This is how such a URL could look like:
Each time you deploy again, you will get a new one. This is perfectly suitable for staging your project until it's ready for production. Once that moment has come, however, you need to provide your users with a definite domain for accessing it.
With the release of now, also introduced a DNS service called zeit.world, which makes the process I've mentioned above very easy:
The only thing you need to do if you want to add a custom domain using this method is point your domains to our nameservers and then alias a deployment by running this command after deploying:
now alias <the-unique-url> <the-domain>
As an example, adding an the alias "domain.com" to the URL I've shown above, would work like this:
now alias https://my-app-qbncycxjue.now.sh domain.com
After you've run the command, now will check if your domain points to a at least four namservers of ours, automatically provision an SSL certificate and assign the new domain to your deployment as an alias.
In turn, your deployment would then be reachable at "domain.com" on the web.
Previously, you've been able to use external nameservers by simply creating a CNAME record with a value of alias.zeit.co and adding an alias using the now alias command.
From now on, this will be slightly different: You need to create a TXT record containing a token for authorization in addition to any CNAME or ALIAS records.
The following example is demonstrating how you can use Cloudflare with now. However, this workflow just works the same for any other external DNS service:
Firstly, add the domain to now using the --external flag:
now domain add --external awesome-now.us
Next, you'll see a token which you need to add as a TXT record to the DNS entries on the platform you're using for DNS management (like mentioned above):
Enable Full (strict) encryption. Without this step your deployments can't communicate with Cloudflare.
Finally, repeat the first step and your domain will be added (you won't see another token this time). Now you can use the domain for one of your deployments!
On some occasions now alias fails to issue a certificate for a deployment when using Cloudflare. In such a case you should try adding a page rule that enforces CloudFlare to use HTTP for the certificate request validation URL. The URL in question is formatted as follows: sub.yourdomain.com/.well-known/acme-challenge/*. In the following screenshot we have a page rule that turns off encryption when accessing a certificate request validation URL of any subdomain of awesome-now.us.
The page rule should no be removed at any time because the verification URL is accessed every time we renew your certificates. In case the rule is removed and the verification URL is inaccessible, we may not be able to renew your certificates successfully, which in turn may make your website or service inaccessible.
Thanks to the now dns sub command within our command line interface, managing existing DNS records on our namservers is as easy as pie. However, don't forget that this only applies to domains you've added using our zeit.world service. In order to modify the records of an externally hosted domain, you need to interact with your DNS provider.
In the examples shown below, the placeholder zeit.rocks represents a domain of your choice that was registered with now domains or now alias. Here are the sub commands you can take advantage of today:
Lists all the DNS records created for domains using zeit.world. The list doesn't include records generated automatically by the nameserver (like a default SOA record, A / AAAA records created automatically for ALIAS records, and so on).