Kasper Souren Kasper Souren - 23 days ago 17
Node.js Question

Meteor: How to get the hostname, server side

On the client I can use

window.location.hostname
to get the hostname. How can I get the same on the server?
I need this to work behind an Apache proxy, unfortunately
Meteor.absoluteUrl()
gives me
localhost:3000
. I also want it to work for different domains, I want one Meteor app that gives different results for different domains.

This question is somewhat related: Node JS get server hostname of current process

Answer

Meteor.absoluteUrl() given that your ROOT_URL env variable is set correctly.

See the following docs: http://docs.meteor.com/#meteor_absoluteurl.

Meteor doesn't know the outside-facing address of the proxy that it's sitting behind, and the (virtual) domain that this proxy was accessed by would have to be forwarded to the Meteor app for it to do what you are asking for. I don't think this is currently supported.

Comments