Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku custom url works as redirect instead of alias

Tags:

url

heroku

I added domains to my heroku project:

 $ heroku domains
=== diveintoworld Heroku Domain
diveintoworld.herokuapp.com
=== diveintoworld Custom Domains
Domain Name            DNS Target
─────────────────────  ───────────────────────────
diveintoworld.com      diveintoworld.herokuapp.com
www.diveintoworld.com  diveintoworld.herokuapp.com

$ host www.diveintoworld.com
www.diveintoworld.com is an alias for diveintoworld.herokuapp.com.

Created CNAME record in my domain settings:

www.diveintoworld.com. CNAME diveintoworld.herokuapp.com.

And set up web redirect from diveintoworld.com to www.diveintoworld.com.

Seems like nothing was missed but all these things work like redirect.
www.diveintoworld.com->diveintoworld.herokuapp.com

But I need to make my site available under www.diveintoworld.com. (When user see my site he should see this url rather than heroku url in his address line.)

like image 515
rocknow Avatar asked Apr 13 '16 11:04

rocknow


1 Answers

When I run

curl -s -I www.diveintoworld.com

It returns a 301. Which means that your app might be doing the unexpected redirect.

HTTP/1.1 301 Moved Permanently
Server: Cowboy
Connection: keep-alive
X-Powered-By: Express
Location: https://diveintoworld.herokuapp.com/
Vary: Accept, Accept-Encoding
Content-Type: text/plain; charset=utf-8
Content-Length: 70
Date: Thu, 21 Apr 2016 05:34:24 GMT
Via: 1.1 vegur

X-Powered-By: Express is from the express.js framework which I'm assuming is the one you used to develop your website. Do you have somewhere in your app code a redirect to the heroku url? Perhaps an environment specific config that sets the app host?

UPDATE - SOLVED

The problem was a misconfiguration of the HEROKU_URL in the configuration of the app. In this case the Ghost platform was used and the config documentation for the url is available here.

Setting HEROKU_URL with http://www.diveintoworld.com, clearing cache or trying in private tab did the trick.

like image 110
Marc Lainez Avatar answered Oct 04 '22 23:10

Marc Lainez