question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redirect Route abortReason caught before use

See original GitHub issue

In the code

/**
 * The default aborted transition handler for new routers.
 */
function defaultAbortHandler(abortReason, location) {
  if (typeof location === 'string')
    throw new Error('Unhandled aborted transition! Reason: ' + abortReason);

  if (abortReason instanceof Cancellation) {
    return;
  } else if (abortReason instanceof Redirect) {
    location.replace(this.makePath(abortReason.to, abortReason.params, abortReason.query));
  } else {
    location.pop();
  }
}

The location is always a string, hence the rest of the code fails. I’ve got an example of the problem at https://github.com/CaseyLeask/react-router-mega-demo/commit/ffb06da63677546e3296e675aa22bb32cad21629

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
benjiecommented, Mar 4, 2015

I’ve only just started with ReactRouter, I’m using the following which seems to work:

middleware = (req, res, next) ->
  router = Router.create
    routes: routes
    location: req.url
    onError: (error) ->
      next(error)
    onAbort: (abortReason) ->
      if abortReason.constructor.name is 'Redirect'
        {to, params, query} = abortReason
        url = router.makePath(to, params, query)
        res.redirect url
      else
        next(abortReason)

  router.run (Handler, state) ->
    # ...
0reactions
shyambalu-sellacocommented, Feb 10, 2015

What was the conclusion on this, I’m running into the same error. I need to override the onAbort function on server?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redirect Route abortReason caught before use #612 - GitHub
The default aborted transition handler for new routers. */ function defaultAbortHandler(abortReason, location) { if (typeof location ...
Read more >
Redirect Vue Router to intended page after a user signs in
I have a catch all route guard that checks if the user is signed in when trying to access a page and redirects...
Read more >
JavaScript create Examples, react-router.create JavaScript ...
JavaScript create - 30 examples found. These are the top rated real world JavaScript examples of react-router.create extracted from open source projects.
Read more >
HTTP Redirects - The PHP Framework For Web Artisans
There are several ways to generate a RedirectResponse instance. The simplest method is to use the global redirect helper: Route::get('/dashboard', function ...
Read more >
Stop using client-side route redirects - Kent C. Dodds
First, the goal of using a client-side redirect (like with Redirect's from prop or similar) is to ensure the user doesn't land on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found