Security

CSRF Protection

Double-submit cookie CSRF prevention.

1 min readDocumentationEdit this page

Usage#

typescript
import { csrf } from '@AxilJS/security'
app.use(csrf())

How it works#

  1. Server sets a random token as a cookie
  2. Client sends the token as x-csrf-token header
  3. Server compares using constant-time comparison

Safe methods (GET, HEAD, OPTIONS) skip validation.

Help improve the documentation

AxilJS is open source and documentation improvements are welcome.

AxilJS DocumentationMIT License · Built by SyntaxilitY