Cannot GET error handler

I want to customize my error handler (Cannot GET / error 404). How can i do this?

In what context is this? Exactly what are you doing that may cause a 404 error?

I assume, but may be wrong, the question is whether you can create a flow that will serve a custom 404 page if nothing else matches the requested URL - rather than get back the default Cannot GET /some-random-url message.

The short answer is that no, we don't provide a way to do that reliably.

You could create an HTTP In node with a path of *. That will match any request that has not been matched yet. In other words, if that is the last HTTP In node to register itself, it will act as a catch-all route.

The problem will come if you add another HTTP In node after it for a route you do want to handle - it will be added after the catch all, so requests won't reach it. You'd also get into difficulty if you use the 'modified-flows/nodes' types of deploys at that will stop/restart individual nodes and cause the route handling to be reordered.

I can't immediately think of an easy way to work around that.

I was hoping that in settings.js, since inside express, you can add something like this...

app.use(function(err, req, res, next) {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});

and use this as the last route.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.