Skip to main content

Function: createCsrfMiddleware()

createCsrfMiddleware(options?): RequestHandler

Defined in: service-core/src/http/csrf/csrf.ts:250

Standalone global-middleware form of the same check RouteUtils.checkCsrf() installs automatically on every route. Useful for a service that registers its own middleware chain directly instead of going through RouteUtils (or that wants a single global registration instead of a per-route one). Always lazily issues the cookie first (see ensureCsrfCookie()), then enforces the check only when req.auth?.source === "cookie" — the same gate RouteUtils.checkCsrf() uses.

Parameters​

options?​

CsrfCheckOptions = {}

Returns​

RequestHandler