OptionalallowWhether unsafe requests without Origin or Referer are allowed.
Defaults to true so server-to-server calls, tests, and older same-origin
clients keep working. Set to false for cookie-backed browser-only APIs.
OptionalprotectedUnsafe HTTP methods protected by the hook.
Defaults to POST, PUT, PATCH, and DELETE.
OptionalskipApp-owned escape hatch for routes that have another verifier, such as provider webhooks or auth callbacks.
OptionaltokenOptional double-submit cookie token check.
When configured, protected requests must send the same token in the configured header and cookie.
OptionaltrustedAdditional trusted origins allowed to send protected requests.
The request URL's own origin is always trusted. Use this for sibling
frontends such as https://app.example.com calling https://api.example.com.
OptionaltrustedHook-local trusted-proxy policy used when comparing the request's external
origin against Origin or Referer. This overrides the server-level
policy.
Configure this only when the app is always behind a platform or reverse
proxy that strips or normalizes forwarding headers. Without this option,
CSRF uses the requestInfo resolved by createServer(...).
Options for
createCsrfHooks(...).