Join our community

Get access to the complete guide to developing and deploying fast, production-ready Nuxt apps.

5-15 Auth and Server Routes

In this lesson, we use server middleware to protect our lesson endpoint.

We use the middleware to add our user to every request, then create a composable utility that uses this user to protect our route.

Finally, we make sure we’re passing cookies with our requests so that we don’t have any SSR issues.

Server middleware: https://nuxt.com/docs/guide/directory-structure/server#server-middleware useRequestHeaders: https://nuxt.com/docs/api/composables/use-request-headers

This course was originally built with Nuxt 3, but it's no longer being maintained. You can still follow the lessons, but make sure to use the exact dependency versions listed in the course repository to avoid breaking changes.

If you’re looking for the most up-to-date and fully supported version, we recommend Mastering Nuxt: Full Stack Unleashed , which uses Nuxt 4 and actively being maintained.