Get subdomain on server without iron router in collection hook


I’m using angular-meteor to write a multi-tenant app, so I’m not using Iron router. I would like to be able to get the subdomain that the user is accessing the page from within a collection hook. (I am using the separate collection hooks package) This parameter will only be used if a trusted superadmin is accessing the page over SSL so it will be trusted input. I just can’t for the life of me figure out how to get this. I tried using this.connection.httpHeaders, however, this only works in publish and meteor subscribe methods. It must be so simple, but I just can’t figure it out. I’m asking here, because there is probably someone who knows much better than I and could point it out in a second.


well, it seems that the hooks can run within publish functions and not within publish functions if you scan all the way to the bottom here:

So, if it occurs within a publish function, you could fork the package, and add the this.connection.httpHeaders code you’re aware to the same place where the userId is made available. But that wouldn’t work for, say, cron code running in setInterval, but perhaps thats fine.