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:

http://dev.localhost:4200/users

I would need to parse out "dev" and send it in the request headers. How would I get that subdomain and/or the url.

Answers


First get hostname and then subdomain

let hostname = window.location.hostname; // `dev.localhost` for you

let [subdomain] = hostname.split('.');   // `dev`

Need Your Help

ADB not recognising Nexus 4 under Windows 7

android adb nexus-4

I'm running on Windows 7, and I've updated all the drivers as it says on the Android developer website regarding using hardware devices. However, Eclipse is still not recognising my Nexus 4 when I ...