Meteor infinite redirect instead of render 404
Asked Answered
C

2

2

I have a simple iron-router config in my /lib/router.coffee:

Router.configure
  notFoundTemplate: "notFound"

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

When entering on / it's works, but if I try go to /abc then it redirects me at /#!abc, after that it redirects me at /abc and so repeated endlessly (I see these changes in the address bar of a browser, in the browser log redirection from / to /abc and back). I never see a 404 error.

Has anyone encountered such behavior?

I use Meteor v1.0.2.1. There is my meteor list:

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

I also use Framework7 in client side.

Chromomere answered 5/1, 2015 at 21:36 Comment(1)
For further reference: This error only occurs when I have the appcache package enabled.Mahala
P
5

What you have is an old iron-router API, in new one my last route looks like this:

Router.route('/(.*)', function() {//regex for every route, must be last
    if (this.ready()) {
        document.title = "404";
        this.render('error');
    } else this.render('loading');
})
Phyllisphylloclade answered 6/1, 2015 at 1:23 Comment(2)
I have used this URL and this is what I need. But it seems to me that it does not explain the endless redirection.Chromomere
Well since iron-router doesn't have 404 error I did it in a way around as you see above, try it instead of Router.configurePhyllisphylloclade
K
0

Try adding a default layoutTemplate in your call to Router.configure(). notFoundTemplate is designed to populate the yield of a main layout template, rather than serve as a replacement layoutTemplate.

Keelin answered 5/1, 2015 at 21:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.