How to make redirect in Hapi

This tutorial is compatible with Hapi v17.8.1
To create a simple redirect we can use the .redirect() method in the handler of route. This method takes a relative or an absolute URI used to redirect the client to the passed resource. It sets the 302 HTTP redirection:

Also, the second way to set the 302 redirect:

The 301 or permanent redirect you can make in two ways:

OR using the .permanent method:

The full example of server:

Learning Hapi.js? Buy my Hapi.js Handbook🔥

If you liked this, please help spread the word by hitting the recommend button below. Thanks!