flow-router: Add triggers support for notFound routes

When I add a notFound handler I would expect it to also support triggers because it mimics the interface of the normal routes. But if I go to a unknown route with following notFound handler:

function trigger () {
    debugger;
}

FlowRouter.notFound = {
    triggersEnter: [trigger],
    action: function() {
        debugger;
    }
};

The triggersEnter doesn’t get executed at all.

This is clearly a problem for me as I want to do a hard browser load on the requested not found url. But the action handler doesn’t have the context of the original request just the ‘*’ route.

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

You can do it via the Meta package and use it through the action function. There you can set the status code to 404. Here’s my snippet

FlowRouter.notFound =
    action: ->
        if Meteor.isClient
            Meta.set [
                {
                    name:"name"
                    property:"prerender-status-code"
                    content:"404"
                }
                {
                    name:"name"
                    property:"robots"
                    content:"noindex, nofollow"
                }
            ]

        BlazeLayout.render "layout",
            content:"not_found"