Locked lesson.
About this lesson
Changing your Heroku app name and using your own domain name.
Exercise files
Download this lesson’s related exercise files.
Adding Custom URLs and Custom Domain Names.docx58.9 KB Adding Custom URLs and Custom Domain Names - Solution.docx
59.9 KB
Quick reference
Adding Custom URLs and Custom Domain Names
In this video I'll show you how to change the URL of your heroku app and how to add a custom domain name.
When to use
If you're ever building a real app, you'll want to use your own domain name. Heroku makes it easy.
Instructions
To change the name (and url) of your heroku app, enter this command in the terminal:
heroku apps:rename NEWNAME
*be sure to change NEWNAME to whatever name you wish to change your app to.
Next: Add that new name to your config/environments/production.rb file:
config.action_mailer.default_url_options = { host: 'NEWNAME.herokuapp.com'}
*be sure to change NEWNAME to whatever name you changed your app to.
Next: Be sure to save your code to git, and then push to github and heroku.
To use a custom domain name like YOURNAME.com for your URL, head over to Heroku.com and sign into your account. Click on the app that you're working on, then click on settings and scroll down to the "Domains and Certificates" section.
To add a custom domain, click the "Add Domain" button and type it in.
You'll next need to add a reference to the new DNS target listed on the screen as a CName at your Registrar.
Check the support section of your specific registrar to find exact instructions for your specific registrar or contact their support department and ask for instructions.
Hints & tips
- Using a cutom Heroku app name can make building your app easier
- Using a custom domain name like yourname.com is easy with Heroku, just add the change to Heroku settings
- 00:04 We're basically done here.
- 00:05 The last thing I wanna talk about real quickly is Heroku URLs.
- 00:09 This I mentioned back at the beginning of the course that it was pretty easy to
- 00:12 change this if you wanted to.
- 00:14 So that's what we're gonna do in this video.
- 00:16 And I'm also gonna show how to use your own custom domain names as well.
- 00:20 So let's go ahead and change this.
- 00:21 So that's long and weird looking.
- 00:24 Just head over to the command line, and pop in this command.
- 00:27 Heroku apps:rename.
- 00:29 And then rename it something, pinteresting4141.
- 00:33 It has to be unique, that's the only thing.
- 00:38 So, that looks like that worked.
- 00:40 Now we need to come up to our config > environments > production.rv.
- 00:44 And remember, we added this URL back at the beginning to tell
- 00:48 our development environment what the Heroku URL is.
- 00:51 So we need to change that to pinteresting4141.
- 00:57 And that should work, now let's save our code.
- 01:04 Change to heroku app name.
- 01:07 Get push.
- 01:09 And let's go ahead and push it up to heroku.
- 01:12 Get push heroku master.
- 01:14 Okay, so then we can come back here, paste in.
- 01:23 And hopefully, if all went well, boom, it worked.
- 01:25 So that was pretty easy.
- 01:27 Now, how do we use our own domain name, like myname.com?
- 01:31 Well, to do that, we go back to heroku, log in with your account, and
- 01:36 scroll down and find the app that your working on is our pinteresting4141,
- 01:42 we just renamed it and click on settings.
- 01:45 And if we scroll through here, we see this domains and certificates section.
- 01:51 So here's our current domain.
- 01:52 If we want to add a custom domain we just click it in here, type in myname.com.
- 01:59 Whatever happens to be, and now we see this DNS target right here.
- 02:02 You'll gonna need to copy this,
- 02:04 and whenever you have your own domain name you have something called the registrar.
- 02:08 That's where you purchase your domain name from,
- 02:10 and they'll have a settings section where you can change, add an a_name or a c_name.
- 02:15 And we want c_name, you can see there.
- 02:17 And find the field for c_name and paste this in there and save it, and
- 02:21 that should do the trick.
- 02:22 Now, sometimes it's a little bit more tricky than that, but
- 02:24 you can Google your registrar.
- 02:26 I used Namecheap.
- 02:27 I would do a Google search and look for Namecheap Heroku domain name and
- 02:31 you'll find a tutorial on exactly how to do it.
- 02:34 Usually in the support center of your registrar.
- 02:37 So if you use GoDaddy they have their own instructions.
- 02:39 If you use Namecheap they use their own instructions.
- 02:41 Whatever register and there's thousands of registrars and
- 02:45 they all do it slightly different but basically what you want to do is add this
- 02:49 thing right here as a new C name in your DNS records.
- 02:52 So, if you can't figure it out, talk to the tech support people of your registrar.
- 02:56 Say hey I got an app at Heroku, I'm trying to point my domain name towards it,
- 02:59 how do I do it?
- 03:00 And they'll just tell you, or show you, or maybe even just do it for you, but very,
- 03:04 very easy.
- 03:05 I'm gonna delete that.
- 03:07 But that's where you do this.
- 03:08 You just log into Heroku, click on your app, click settings,
- 03:11 scroll down to the domains, and that is pretty much it.
- 03:14 So it's that easy to add a domain name,
- 03:17 it is that easy to change the name of your app.
- 03:20 In this case I would not use a custom domain name because the good folks at
- 03:24 Pinterest might actually come after you for copyright infringement, but
- 03:27 we can continue to use this Pinteresting4141.
- 03:31 Name it whatever you want, John Elders Pinterest, whatever your name is use that.
- 03:35 Whatever you want just have some fun with it.
- 03:37 So, that's all for this video
Lesson notes are only available for subscribers.