I have a meteor app that uses iron router. Every time I refresh the browser or input a url like http://localhost:3000/gigs
my app refreshes back to the base url of just http://localhost:3000
Here is my router.js code
var requireLogin = function() {
if (!Meteor.user() && !Meteor.loggingIn()) {
Router.go('signIn');
this.stop();
}
};
Router.configure({ loadingTemplate: 'loading' });
Router.before(requireLogin, {only: ['tasks', 'gigs']});
Router.map(function() {
this.route('tasks', {
path: '/',
waitOn: function() { return [ Meteor.subscribe('projects'), Meteor.subscribe('tasks') ] },
layoutTemplate: 'twoColMenuLayout',
template: 'tasksList',
yieldTemplates: {l
'taskDetail': {to: 'rightTemplate'}
},
data: {
moduleName: 'projects'
}
});
this.route('gigs', {
path: '/gigs',
waitOn: function() { return [ Meteor.subscribe('gigs') ] },
layoutTemplate: 'twoColMenuLayout',
template: 'gigsList',
yieldTemplates: {
'gigDetail': {to: 'rightTemplate'}
},
data: {
moduleName: 'gigs'
}
});
this.route('gigSubmit', {
path: '/gig-submit',
layoutTemplate: 'oneColMenuLayout',
template: 'gigSubmit',
data: {
pageTitle: 'New Gig'
}
});
this.route('signIn', {
path: '/signIn',
layoutTemplate: 'blankLayout',
template: 'signIn'
});
});
The strange thing is that if I change the 'tasks' path to be '/tasks' instead of '/' this problem doesn't occur and it works as I would expect it to. However when I do that I get a console error message that no '/' is defined. It doesn't seem to break anything but I hate having errors in the console.
I've also tried moving the 'tasks' map to the bottom in case it was matching first on this one and always going there, but that didn't make a difference.
Any idea why this is happening?
Thanks!