MiddlewareOptionsinterface
import { MiddlewareOptions } from '@mortar-kit/auth'
interface MiddlewareOptionsOptions for createMiddleware.
Properties
auth: Auth<unknown>The site's
createAuth(orauthFromEnv).blobs?: BlobStoreServes uploaded files from this store at the path its
url('')gives (e.g./uploads/), withserveBlob.rateLimit?: false | { max: number; window: number }Limits sign-in attempts (posts to the auth routes) per client:
maxin eachwindowof seconds, then 429 with Retry-After. Asking for a code or link and trying one count separately, so a client that used up its sends can still type the code it got. Default{ max: 10, window: 600 }for each;falseturns it off. Kept in memory, per server process.clientKey?: (request: Request) => string | undefinedWho a request is from, for the rate limit; undefined means not limited. Default: the first address in
X-Forwarded-For, elseX-Real-IP, which a proxy in front of the server sets. Without a proxy, a Fetch Request doesn't carry the client's address: pass your own (a shared bucket for everyone would let one client lock every editor out).csp?: string | booleanA Content-Security-Policy for HTML responses.
true(default) sendsscript-src 'nonce-…' 'strict-dynamic'; object-src 'none'; base-uri 'none'; frame-ancestors 'self', with a fresh nonce per request that the page render puts on its scripts; a string is your own policy, where{nonce}is replaced by that nonce;falsesends none. The server entry must pass the nonce torenderToStream(the plugin's generated entries do). Default off on the dev server (dev), since Vite's dev scripts carry no nonce.headers?: false | Readonly<Record<string, string | null>>Headers for every response, unless it set them itself. Default
X-Content-Type-Options: nosniff,Referrer-Policy: strict-origin-when-cross-originandX-Frame-Options: SAMEORIGIN(the admin's preview is a same-origin frame). Yours are added to those; a header set tonullis left out;falseadds none.sitemap?: { content: ContentSource; collections: readonly AnyCollection[] } & Omit<SitemapOptions, "origin"> & { origin?: string }Answers
GET /sitemap.xmlwithsitemap(content, collections, options)from@mortar-kit/core.origindefaults to the request's; set it behind a proxy (e.g. fromMORTAR_BASE_URL).robots?: string | booleanAnswers
GET /robots.txt.truelets crawlers in everywhere but the auth's protected paths (/admin) and points them at the sitemap whensitemapis set; a string is the whole file. Default: not served.dev?: booleanDevelopment: no CSP by default. Default Vite's
import.meta.env.DEV.