Vapor Documentation Beta

Enumeration CORSMiddleware.​Allow​Origin​Setting

public enum AllowOriginSetting

Option for the allow origin header in responses for CORS requests.

  • none: Disallows any origin.

  • originBased: Uses value of the origin header in the request.

  • all: Uses wildcard to allow any origin.

  • any: A list of allowable origins.

  • custom: Uses custom string provided as an associated value.

Member Of

CORSMiddleware

Middleware that adds support for CORS settings in request responses. For configuration of this middleware please use the CORSMiddleware.Configuration object.

Enumeration Cases

none

case none

Disallow any origin.

origin​Based

case originBased

Uses value of the origin header in the request.

all

case all

Uses wildcard to allow any origin.

any

case any(: [String])

A list of allowable origins.

custom

case custom(: String)

Uses custom string provided as an associated value.

Methods

whitelist(_:​)

@available(*, deprecated, renamed: "any") public static func whitelist(_ origins: [String]) -> Self

header(for​Request:​)

public func header(forRequest req: Request) -> String

Creates the header string depending on the case of self.

Parameters

request

Request for which the allow origin header should be created.

Returns

Header string to be used in response for allowed origin.