Search code examples
javascriptmeteoriron-router

Meteor router working in dev mode but not in production mode


I'm trying to protect an admin page, so I created a role for it. I'm using iron:router for the routes, and in production mode I have an issue: everytime I type the url/admin in my browser, I end up in /user (it's the login page). I don't have this issue in dev mode ! I really don't get why

Here is the code:

var middleware;

middleware = {
  isAdmin: function() {
    var user;
    user = Meteor.user();

    if (!Roles.userIsInRole(user, ['admin'])) {
      this.redirect('user');
      return;
    }

    return this.next();
  }
};

And for the router: (in

Router.map(function() {
  this.route('user', {
    path: '/user'
  });
  return this.route('admin', {
    path: '/admin',
    before: [middleware.isAdmin]
  });
});

Solution

  • So in fact I just used fast-render, which automatically solves my problem. Hope it'll help somebody !