Skip to content

cors

cors: (options?) => Function

Defined in: http/cors.js:46

Creates a CORS validation middleware.

CORS policy options forwarded to lib/cors

boolean

Whether to allow credentials

string | Function | RegExp | string[]

Allowed request headers

string[]

Allowed HTTP methods

string | string[]

Headers to expose to the client

number

Preflight cache duration in seconds

string | Function | RegExp | string[]

Allowed origins

Function

  • Ergo middleware that returns undefined for non-CORS requests, {response: {headers}} when allowed, or {response: {statusCode: 403}} when denied