How to get subdomainName in Ember-cli (2.3)
I have an ember-cli project using ember2.3 that is proxying to a server api. Right now, for my development environment, for example, I use this to proxy to the node server at :3000.
ember serve --proxy http://localhost:3000/
Part of my server side code needs the subdomain of the url to fetch data. Before, in Ember1.7, because I was not using ember-cli and not proxying, the subdomainName could be gotten via req.subdomains. But now, i need to make sure that the subdomain is being sent in the request's headers via the RESTAdapter.
Therefore, I need a way to get the current url and subsequently the subdomain of the url that the application is at.
For example, if I were current at the path:
I would need to parse out "dev" and send it in the request headers. How would I get that subdomain and/or the url.
First get hostname and then subdomain
let hostname = window.location.hostname; // `dev.localhost` for you let [subdomain] = hostname.split('.'); // `dev`