The cookie object to use for storing the CSRF token. Should be configured with httpOnly, secure (in production), and sameSite: "lax" or "strict".
OptionalformThe name of the form field containing the CSRF token.
OptionalonCustom handler for requests with invalid CSRF tokens. Use this to log attempts, return custom error responses, or implement additional security measures.
OptionaloriginTrusted origins that bypass CSRF token validation.
When a request comes from a trusted origin, the middleware skips token validation and allows the request through. This is useful for allowing cross-site form submissions from specific trusted domains.
The origin is extracted from (in order): Origin header, Referer
header, or request.referrer property.
OptionalsafeHTTP methods that bypass CSRF validation. These methods are considered safe because they should not cause side effects.
OptionalsecretA secret to sign the CSRF token for extra security. When provided, tokens are signed and validated against tampering.
Configuration options for the CSRF token middleware.