Closed minustime closed 7 years ago
The variety in case of an error response is not 'view' (it is undefined), so the response object is not extended with the template helper. Also, the 'onPreAuth' extension point is not called in case of an error. Can you use another strategy to handle your 404 errors?
The way I implemented the error page is the one outlined in their API docs:
When a different error representation is desired, such as an HTML page or a different payload format, the 'onPreResponse' extension point may be used to identify errors and replace them with a different response object.
I'll think of an alternative solution, but I think this issue will trip other users of the plugin.
(Thanks for making this plugin available btw!)
The problem is that the 'onPreAuth' extension point is not called. If I use the 'onRequest' extension point (which is called in case of an error) the request object is lacking the language code.
I am sorry but I guess I can't help you out here. If you have a working solution feel free to create a pull request.
I integrated this plugin on my site and works perfectly, however my custom 404 error page generates an internal error:
__ is not a function: templates/404.pug:2
Looks like the onPreResponse part of the plugin never gets called, thus the view doesn't know what
__
is.server.js
404.pug
Please see a complete example here: https://github.com/minustime/hapijs-localization-test