Protecting an endpoint
You need to be sure to import the AuthModule
into the imports array in the module you want to use Auth.
To secure a route, use the Nest decorator @UseGuards()
, and passport's AuthGuard()
function as follows:
You can use this decorator at controller level or route level to protect all or only some endpoints.
Last updated