Adding Route Protections with Guards
Learn how to protect routes with guards in NestJS.
We'll cover the following
In our virtual library, the /books
endpoint is reserved for authenticated users only. In this lesson, we will use a NestJS guard to enforce this restriction by validating JWT tokens attached to incoming requests.
Generating AuthGuard
To generate AuthGuard
, run the nest g guard auth --no-spec
command in the terminal below:
Get hands-on with 1400+ tech skills courses.