Some visitors getting bounced in a redirect loop


#1

I’m not sure how this is happening, as none of my colleagues can replicate this. Basically I have a special URL, /ref/XXXX where XXXX is a tracking ID, which is looked up in a MongoDB, and only certain products (slugs) are shown to the visitor. The products are retrieved by looking up this tracking ID, and a session variable is set to limit the subscription to those products. This is done using Iron Router. See below:

Router.route('/ref/:trackingId', {
  data: function () {
    return TrackingIds.findOne(this.params.trackingId);
  },

  onBeforeAction: function () {
    var trackingData = this.data();

    if (trackingData) {
      Cookie.set('prodlimit', this.data().slugs, {
        path: '/',
        expires: 14
      });
      Session.set('limitProductsTo', {slug: {$in: this.data().slugs}});
    } else {
      Session.set('limitProductsTo', {});
    }
    Router.go('landingPage');
  }
});

So for me and some other people, it works fine. But Google Analytics is showing a redirect loop where the user is bounced from /ref/xyz to /, then to /ref/xyz again, then to /, and so on. I don’t see how this is possible since the root route never ever redirects to /ref/xyz. Am I missing something here? Am I doing something wrong in Iron Router?


#2

Its hard to tell by this piece of code (it seems normal). Maybe something in ‘/’ route? Or in ‘landingPage’ route? Or redirect occurring in templates?