Skip to content

CsrfOptions

readonly allowedOrigins: readonly string[]

Origins allowed to send mutations, 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 mutations 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 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.