Skip to content

CsrfOptions

readonly allowedOrigins: readonly string[]

Origins allowed to send unsafe requests, such as https://app.example.


readonly optional allowSameSite?: boolean

Accept Sec-Fetch-Site: same-site too, for sibling subdomains you trust. Default false.


readonly optional crossSiteOrigins?: readonly string[]

Exact origins allowed to send unsafe requests from another site, such as a desktop shell on its own scheme (app://desktop). An origin listed here counts as allowed, and its Sec-Fetch-Site: cross-site requests pass; the double-submit token is still required. Matched exactly, no wildcards. Trust each one as much as your own origin. Default none.


readonly optional exempt?: readonly (string | RegExp)[]

Paths that skip CSRF entirely, such as a webhook that authenticates with a signature. A string matches the request path exactly (a global prefix included); a RegExp is tested against it. Exempt requests are still subject to the session guard.


readonly optional headerName?: string

Header the page echoes the token in. Default x-csrf-token.


readonly secrets: readonly (string | Uint8Array<ArrayBufferLike>)[]

Signs the double-submit token. At least 32 bytes each, and not the auth secret. Current secret first, previous ones after it during a rollover: a safe request replaces a token signed by a previous secret with one under the current secret.