Find the url that the client connects to Meteor server with

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

1 Like

Try Meteor.absoluteUrl().

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

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

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

1 Like

Is this not possible?

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.