Search code examples
meteorflow-router

Meteor - Flowrouter: generic vs variable route


I want to display posts for different cities, defined by cityId:

FlowRouter.route("/:cityId", {
   name: 'postList',
   action: function() {
      console.log(FlowRouter.getParam("cityId"));
      return BlazeLayout.render('mainLayout', {
        top: 'header',
        body: 'postList'
      });
    }
});

Alongside with that I of course have generic routes like 'admin', 'signup' and so on.
But when I go to /signup, the postList route gets activated, treating 'signup' word as a city id, and 'signup' is logged in console.
Defining route like FlowRouter.route("/postList/:cityId") is not an option.


Solution

  • Actually, you need to control route definition order.
    define the /signup route before the generic one: /:cityId