Find the url that the client connects to Meteor server with


#1

I would like my Meteor application to ‘skin’ differently depending on which URL the client used to connect… e.g. https://iHeartCats.com vs https://iHeartDogs.com - so I’d like to be able to the connection string (from t

What is the most robust way to do this with Meteor on the Server side, and that will work for example with Galaxy?

Of course if the client just connects via the server’s IP address I can’t tell anything, but I can handle that case with a default (dogs of course :slight_smile:). Also, For the client side I realize I can just use window.location etc


#2

Try Meteor.absoluteUrl().


#3

That isn’t going to work for this scenarios - it appears to be based on the server config; not on the path the client used in order to connect

. I plan to have multiple DNS names pointing to the same set of IPs


#4

Ah, have you tried using just basic window.location.href?


#5

My questions is about server side. I did mention in my question when I posted it that I know I can do that on client side… Of course I could just send that up in a Meteor.call etc, but that seemed ugly


#6

Is this not possible?


#7

You can probably leverage connection.httpHeaders.host on the server side. You can access this in methods and publish functions server side (via this.connection). As a quick test, try adding the following to your /server/main.js:

Meteor.onConnection((connection) => {
  console.log(connection.httpHeaders.host);
});

Access your app from a few different hostnames and you should see the requested hostname in your logs.