Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Domain doesn't work without `www`, what's the fix in node.js [closed]

I know this question has been asked Domain doesn't work without www

But I need a solution for node.js app hosted on heroku and using namecheap with komodo

Also, I found this similar thing which i didnt' understand at all.

Can someone give an example of how to handle this in node.js?

Details: I'm using express. In Heroku I have

example.me(Domain Name)   yamanashi-3938.herokussl.com (DNS Target)

www.example.me(Domain Name)   yamanashi-3938.herokussl.com(DNS Target)

In Namecheap I have:

 @ | https://www.example.me | URL redirect 
www | yamanashi-3938.herokussl.com. | CNAME
like image 995
Martian2049 Avatar asked Sep 05 '25 01:09

Martian2049


1 Answers

www.example.com and example.com are different records in the DNS. You need to make sure both are pointing to the same place. You can either set both to point to the same address or setup the example.com to redirect to the www.example.com.

If you're using namecheap it should look something like this.

+------------+---------------------------+--------------+
| Host Name  |      IP Address/URL       | Record Type  |
+------------+---------------------------+--------------+
| @          | http://www.yourdomain.com | URL Redirect |
| www        | app-name.herokuapp.com.   | CNAME(Alias) |
+------------+---------------------------+--------------+

Make sure you also add the domain under your Heroku project settings.

like image 163
dmlittle Avatar answered Sep 07 '25 20:09

dmlittle