Use Now alias for custom sub-domains

Andy Van Slaars
InstructorAndy Van Slaars
Share this video with your friends

Social Share Links

Send Tweet
Published 7 years ago
Updated 5 years ago

Now is a great way to deploy your node application, but the generated URLs aren't memorable or easily remembered. With Now's alias command, you can fix that. In this video lesson we'll cover how to add an alias to a deployment, giving you a custom *.now.sh subdomain, how to create an alias using your own custom domain name, how to list your aliases and finally how to remove an alias if you no longer want it.

[00:00] Here I have a simple Hello World application built with Express. I have this application deployed to Now. If I look in a browser, we can see that it's running as expected. I'd like to give my application a URL that's a little easier to read and remember. In the terminal I'm going to type in Now LS to list out my deployments. I'd like to give my most recent deployment an easier URL.

[00:19] I'm going to grab the deployment ID and I'm going to type in now alias, paste that ID in, and then I'm going to give it an alias value. In this case I'm just going to throw my initials in there.

[00:32] That's going to be part of the URL, so instead of this value here, where it says Now Demo-PPFC, etc., it's going to say abs.now.sh. I'm going to press Enter and we'll see the alias has been successfully added. Now I have a new URL that's much shorter and easier to remember. Back in the browser, I can update my URL to use my new alias value and everything works as expected.

[00:58] It's important to note that this alias doesn't replace my original URL. I can still paste that back in here and everything will still work. Anybody that has that old link that clicks on it will still get to my site.

[01:11] Let's say instead of just a now.sh subdomain, I want to point a custom domain name at my Hello World application. I can follow the same process. I can type in now alias, the ID of my deployment, and then I can pass a custom domain name.

[01:29] For now, I'm just going to make one up. I'm just going to...abs.demo.org, and this doesn't exist and if it does I don't own it. But that's OK. I'm not going to break anything. I'm going to run this, and it's actually going to verify to see if my DNS settings point to Zite's DNS servers. When it finds out that they don't, it's going to give me some helpful instructions so I can fix this.

[01:52] I've taken a domain name that I do own and I've pointed the name servers to Zite.world DNS servers. I'll just clear this and I'm going to run my alias command again with my ID. This time I'm going to point it to my domain name. My alias has been successfully created, so now I should be able to go to my domain name right in the browser and I'll see my application.

[02:20] If you want to see what deployments you have with what aliases, you can just type in now alias LS and you'll see your alias IDs next to your deployment URL and the alias URL. If you ever want to remove an alias, you can use that ID with Now Alias RM and the ID and you can remove the alias, which we can confirm by doing another list. Now we only have the one.

egghead
egghead
~ 2 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today