流星无限重定向而不是渲染404

时间:2015-01-05 21:36:56

标签: web-applications meteor routing iron-router html-framework-7

我的/lib/router.coffee中有一个简单的铁路由器配置:

Router.configure
  notFoundTemplate: "notFound"

Router.map ->
  @route "app",
    path: "/"
    template: "app"

当进入/它的工作时,但是如果我尝试转到/ abc然后它将我重定向到/#!abc,之后它将我重定向到/ abc并且如此无休止地重复(我看到这些变化)浏览器的地址栏,浏览器日志重定向从/到/ abc和返回)。我从未看到404错误。

有没有人遇到过这样的行为?

我使用Meteor v1.0.2.1。有我的流星列表:

alethes:lodash           0.7.1
appcache                 1.0.3
coffeescript             1.0.5
ground:localstorage      0.1.7
ground:store             0.1.1
ianhorst:bower           0.0.2
iron:router              1.0.6
meteor-platform          1.2.1
meteorhacks:kadira       2.15.2
peerlibrary:async        0.9.0_3
rzymek:moment            2.8.3_10
rzymek:moment-locale-ru  2.8.4

我也在客户端使用Framework7。

2 个答案:

答案 0 :(得分:5)

你所拥有的是一个旧的铁路由器API,在新的路由器中,我的最后一条路线如下:

Router.route('/(.*)', function() {//regex for every route, must be last
    if (this.ready()) {
        document.title = "404";
        this.render('error');
    } else this.render('loading');
})

答案 1 :(得分:0)

尝试在对Router.configure()的调用中添加默认的layoutTemplate。 notFoundTemplate用于填充主布局模板的yield,而不是用作替换layoutTemplate。