How to return 404 using Iron Router

后端 未结 3 1456
星月不相逢
星月不相逢 2021-01-12 01:01

When I hit a route that doesn\'t exist on my Meteor app that uses IR, I get a 200 response with an HTML that (when rendered on a browser) displays a js error on

3条回答
  •  情歌与酒
    2021-01-12 01:32

    this.route('template404', {
      path: '/*'
    }
    

    Use it at the end of your Router.map, cause this catches every value - if you use at the begining every path will be caught to this

    Of course you can make it more complex, for example:

    this.route('template404', {
          path: '/posts/*'
        }
    

提交回复
热议问题