Skip to content

You're viewing documentation for a pre-release version. View the latest stable version

Initializer

init(allowedOrigin:allowedMethods:allowedHeaders:allowCredentials:cacheExpiration:exposedHeaders:)

Instantiate a CORSConfiguration struct that can be used to create a CORSConfiguration middleware for adding support for CORS in your responses.
init(allowedOrigin: AllowOriginSetting, allowedMethods: [HTTPRequest.Method], allowedHeaders: [HTTPField.Name], allowCredentials: Bool = false, cacheExpiration: Int? = 600, exposedHeaders: [HTTPField.Name]? = nil)

Parameters

allowedOrigin

Setting that controls which origin values are allowed.

allowedMethods

Methods that are allowed for a CORS request response.

allowedHeaders

Headers that are allowed in a response for CORS request.

allowCredentials

If cookies and other credentials will be sent in the response.

cacheExpiration

Optionally sets expiration of the cached pre-flight request in seconds.

exposedHeaders

Headers exposed in the response of pre-flight request.