0

Basically, Heroku gives you a domain named by default: XXX.herokuapp.com.

On my own, I have a set of REST apis that I would like to set on a domain named: api.myDomain.com.

On the same time, I have my HTML files (web view) distributed by the same server as the REST API.
It's similar to this; embedding static files on server in a dist folder.

I expect the domain serving those HTML/JS files to be www.myDomain.com.
I thought about putting them clearly on a distinct server dedicated to static files, but the fact is that Single Page Application should be controlled by a server, in order to make the refresh works (F5 redirecting to index.html), that's why I chose to use the same server as REST apis.
An alternative would be to dedicate ANOTHER server to treat only static files, independent of the REST Apis' server.

How to deal with both domains (api and www) while sources being on the same servers?

Or should I completely rethink the strategy?

Mik378
  • 21,881
  • 15
  • 82
  • 180
  • Sounds similar to this: http://stackoverflow.com/questions/15160328/api-subdomain-for-heroku-app-is-it-possible – Mik378 Jan 19 '15 at 16:58

1 Answers1

1

You can just set both domains to direct to your page by setting it up in your app settings, but then I'm pretty sure that would mean api.myDomain.com/dist would show your static things, and www.myDomain.com could show your api things.

https://devcenter.heroku.com/articles/custom-domains

Another way you could do this might be by doing some things with your actual code, but we don't really know what your code is like right now.

Chris
  • 140
  • 9
  • `www.myDomain.com/dist` would show static things. `api.myDomain.com` would show api things. – Mik378 Jan 19 '15 at 17:14
  • If you set both domains, both would show both. That's what I meant. – Chris Jan 19 '15 at 17:17
  • Yes, but what I want to avoid is `api.myDomain.com` to redirect to static files. I like this solution: http://stackoverflow.com/a/15162863/985949. – Mik378 Jan 19 '15 at 17:18
  • Yes, that's what I meant by the code solution but you didn't post anything about yours. Could you add some context about that? – Chris Jan 19 '15 at 17:21
  • I'm using Play Framework 2.3.7 at server side. Just reading this interesting post: https://jazzy.id.au/2013/05/08/advanced_routing_in_play_framework.html – Mik378 Jan 19 '15 at 17:32