Let's create a simple authentication app using Express as Nuxt's server middleware. We will be still using the client-side code from the authentication exercise along with the per-route middlewares that you learned about in the preceding section, where the user is required to provide a username and password to access a secured page. Additionally, we will be using a Vuex store to centralize the authenticated user data just like before. The major difference in this exercise is that our Nuxt app will be moved out of the server-side app as a middleware, and, instead, the server-side app will be moved into the Nuxt app as middleware. So, let's get started by following these steps:
- Install cookie-session and body-parser as server middlewares, and add the path of our API after them in the Nuxt config file, as follows:
// nuxt.config.js
import bodyParser from 'body-parser'
import cookieSession from 'cookie...