Guards
Guard list
| Guard | Description |
|---|---|
CaptchaGuard | Protects HTTP routes by validating a captcha token using the active provider. |
How it works
- Reads the captcha token from headers (default) or body
- Uses
CaptchaService.verifyAsync(token)to validate - Throws
UnauthorizedExceptionif the token is missing or invalid
Usage
example.controller.ts
import { Controller, Post, UseGuards } from '@nestjs/common';
import { CaptchaGuard } from 'nestjs-captcha-module';
@Controller('example')
export class ExampleController {
@Post('submit')
@UseGuards(CaptchaGuard)
submit() {
return { ok: true };
}
}
note
By default, the guard expects the token in the x-captcha-token header.
You can customize this via guardOptions when registering the module.