Configuration
Configuration used for populating headers in response for CORS requests.
struct Configuration
Configuration used for populating headers in response for CORS requests.
struct Configuration
import Vapor
Vapor is a framework for building server applications, APIs and websites in Swift. It provides a safe, performant and scalable foundation for building large complex backends.
final class CORSMiddleware
Middleware that adds support for CORS settings in request responses. For configuration of this middleware please use the CORSMiddleware.Configuration
object.
init(configuration: Configuration = .default())
Creates a CORS middleware with the specified configuration.
let configuration: Configuration
Configuration used for populating headers in response for CORS requests.
func respond(to request: Request, chainingTo next: Responder) -> EventLoopFuture<Response>
enum AllowOriginSetting
Option for the allow origin header in responses for CORS requests.
protocol Sendable
init(allowedOrigin: AllowOriginSetting, allowedMethods: [HTTPMethod], allowedHeaders: [HTTPHeaders.Name], allowCredentials: Bool = false, cacheExpiration: Int? = 600, exposedHeaders: [HTTPHeaders.Name]? = nil)
Instantiate a CORSConfiguration struct that can be used to create a CORSConfiguration
middleware for adding support for CORS in your responses.
static func `default`() -> Configuration
Default CORS configuration.
let allowCredentials: Bool
If set to yes, cookies and other credentials will be sent in the response for CORS request.
let allowedHeaders: String
Header string containing headers that are allowed in a response for CORS request.
let allowedMethods: String
Header string containing methods that are allowed for a CORS request response.
let allowedOrigin: AllowOriginSetting
Setting that controls which origin values are allowed.
let cacheExpiration: Int?
Optionally sets expiration of the cached pre-flight request. Value is in seconds.
let exposedHeaders: String?
Headers exposed in the response of pre-flight request.
init(allowedOrigin: CORSMiddleware.AllowOriginSetting, allowedMethods: [HTTPMethod], allowedHeaders: [HTTPHeaders.Name], allowCredentials: Bool = false, cacheExpiration: Int? = 600, exposedHeaders: [String])
Instantiate a CORSConfiguration struct that can be used to create a CORSConfiguration
middleware for adding support for CORS in your responses.