CanCeylan
CanCeylan

Reputation: 3010

Make api calls to custom heroku domain

I'm building an open API with rails and hosting my project on Heroku. However I want my API calls to be from mydomain.co instead of heroku's domain.

I added my domain from Heroku dashboard, and I also forwarded my domain to heroku's url.

However when I make the 'POST' call like below:

 curl -H "Content-Type: application/json" -d '{"myjsontitle":{"field1":"[email protected]","field2":"12345678"}}' -X POST http://deriva.co/applicants.json 

Terminal returns the following:

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="https://stark-bayou-1773.herokuapp.com/applicants.json">here</a>.</h2>
</body></html>

And when I look at the heroku logs, it says

at=info method=GET path="/applicants.json" host=stark-bayou-1773.herokuapp.com 

How should I fix that problem?

Thanks!

Upvotes: 1

Views: 295

Answers (1)

Simone Carletti
Simone Carletti

Reputation: 176552

There is an error with your DNS configuration.

➜  ~  curl -I deriva.co
HTTP/1.1 302 Found
Cache-Control: max-age=900
Content-Type: text/html; charset=utf-8
Location: https://stark-bayou-1773.herokuapp.com
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 02 Feb 2015 19:59:45 GMT
Content-Length: 155
Age: 67
Connection: keep-alive

deriva.co redirects to Heroku, whereas it should resolve to it. You probably used a sort of provider redirect, which is not the correct DNS configuration. You need to "point" the DNS to Heroku.

Please note that you can't map deriva.co to Heroku directly unless your providers supports a CNAME-like configuration for the root domain. And GoDaddy does not.

You either need to change DNS provider or point www.deriva.co using a CNAME and redirect deriva.co to www.deriva.co.

Upvotes: 2

Related Questions