You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had a use case where I was trying to render a 404 page directly in the NotFound event handler, which was causing some issues. There appears to be some internal handlers that set up some initial state, and the NotFound event was not running through those internal handlers.
In my specific case, req.params was not being given an initial value, so attempting to manually invoke common handler from within the NotFound handler was causing all sorts of issues. For example, restify.queryParser and restify.bodyParser expect req.params to be initialized, so manually invoking them caused Restify to blow up.
I eventually resolved the issue by redirecting the request to a known 404 handler, which would then invoke the internal and common handler stack as expected. I suspect this was a design decision, to have the NotFound handler skip any internal handlers. This makes a lot of sense for lean REST API services, but for a more complex web app may cause some behaviors that are not immediately obvious.
The text was updated successfully, but these errors were encountered:
I had a use case where I was trying to render a 404 page directly in the NotFound event handler, which was causing some issues. There appears to be some internal handlers that set up some initial state, and the NotFound event was not running through those internal handlers.
In my specific case, req.params was not being given an initial value, so attempting to manually invoke common handler from within the NotFound handler was causing all sorts of issues. For example, restify.queryParser and restify.bodyParser expect req.params to be initialized, so manually invoking them caused Restify to blow up.
I eventually resolved the issue by redirecting the request to a known 404 handler, which would then invoke the internal and common handler stack as expected. I suspect this was a design decision, to have the NotFound handler skip any internal handlers. This makes a lot of sense for lean REST API services, but for a more complex web app may cause some behaviors that are not immediately obvious.
The text was updated successfully, but these errors were encountered: