kadirahq / flow-router

Carefully Designed Client Side Router for Meteor
MIT License
1.09k stars 195 forks source link

Uncaught TypeError: str.slice is not a function #555

Closed MHerszak closed 8 years ago

MHerszak commented 8 years ago

I am using 'kadira:flow-router-ssr@3.11.2' and neither redirect nor FlowRouter.go seem to work. I am trying to trigger after an evaluation. "redirect" throws Uncaught TypeError: str.slice is not a function and FlowRouter.go only changes the route for a second and changes it back to the route I just evaluated against. I expected to be redirected, actually.

I attached a screenshot from the browser tools and it seems there is a serious problem with "redirect". The string prototype is actually not a string, its a function. Any idea?

screen shot 2016-03-14 at 11 27 15

Redirect seems to throw an error when I access a route triggersEnter: [function(context, redirect) { redirect('/posts/list'); }],

dtwist commented 8 years ago

I'm bumping into this same error, in the same context:

  // Set group using previous re-direct
  const authenticatedRoutes = FlowRouter.group({
    name: 'authenticated',
    triggersEnter: [function(context, redirect) {
      // Redirect unauthed users to login page
      if (!Meteor.loggingIn() && !Meteor.userId()) {
        console.log('not authorized');
        redirect('/login');
      }
    }]
  });

The log statement is firing without issue. If I replace the redirect with FlowRouter.go, I get the same issue described by @MHerszak

dtwist commented 8 years ago

quick followup—reverting to current stable version of flow-router (not -ssr) corrects this issue. I'm currently using Meteor 1.3-beta.12.

arunoda commented 8 years ago

This is fixed thanks to @marbemac's PR. Update the package.