Express middleware for pjax with redirect