Skip to main content

Function: Public()

Public(): any

Decorator that marks a route as publicly accessible.

Returns

any

Description

When applied to a route handler or controller, this decorator allows the endpoint to be accessed without authentication, bypassing the JWT authentication guard.

Example

// Make a single route public
@Public()
@Get('public-endpoint')
publicEndpoint() {
return 'This endpoint is accessible without authentication';
}

// Make all routes in a controller public
@Public()
@Controller('public')
export class PublicController {
// All routes in this controller will be public
}