gadicc / meteor-headers

Access HTTP headers on both server and client. Client IP with proxy support.
https://atmospherejs.com/gadicohen/headers
GNU Lesser General Public License v3.0
61 stars 21 forks source link

Spiderable doesn't wait for subscriptions inside headers.ready() #48

Closed chongwang87 closed 8 years ago

chongwang87 commented 8 years ago

Hi @gadicc,

i use headers.ready() on Template.onCreated to get current user headers.get('host'), then subscribe data base on the headers.get('host').

everything is able to Spiderable except those subscriptions which subscribed in headers.ready(). is there anyway to make it possible?

here are some example of our use case

Template.layout.onCreated(function(){
    let tpl = this;
    headers.ready(function() {
        tpl.domain = () => headers.get('host');
        tpl.subscribe("company", tpl.domain());
    })
});
gadicc commented 8 years ago

Hey there.

Sorry, but I'm not really sure :/ You could try getting rid of the headers.ready() wrapper and hope it's enough for spiderable.

You might want to also check out prerender, I think a lot of people are switching to it from spiderable... I know Galaxy includes it for free, and prerender.io has a paid service; there miiight also be a Meteor package that does it for free too, I'm not sure.

chongwang87 commented 8 years ago

closing this issue because we use window.location.hostname directly for our tpl.domain()

gadicc commented 8 years ago

Oh haha yeah and that :) I should have thought more about what you actually needed. There's also Meteor.absoluteUrl() based on your ROOT_URL environment variable.