CorsOptions class

CORS configuration options.

The default configuration is the equivalent of:

{
 "origin": "*",
 "methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
 "preflightContinue": false
}

Constructors

CorsOptions({Iterable<String> allowedHeaders = const [], bool credentials = false, int? maxAge, Iterable<String> methods = const ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE'], dynamic origin = '*', int successStatus = 204, bool preflightContinue = false, Iterable<String> exposedHeaders = const []})

Properties

allowedHeaders List<String>
Configures the Access-Control-Allow-Headers CORS header. Expects a comma-delimited string (ex: 'Content-Type,Authorization') or an array (ex: ['Content-Type', 'Authorization']). If not specified, defaults to reflecting the headers specified in the request's Access-Control-Request-Headers header.
final
credentials bool
Configures the Access-Control-Allow-Credentials CORS header. Set to true to pass the header, otherwise it is omitted.
final
exposedHeaders List<String>
Configures the Access-Control-Expose-Headers CORS header. Expects a comma-delimited string (ex: 'Content-Range,X-Content-Range') or an array (ex: ['Content-Range', 'X-Content-Range']). If not specified, no custom headers are exposed.
final
hashCode int
The hash code for this object.
no setterinherited
maxAge int?
Configures the Access-Control-Max-Age CORS header. Set to an integer to pass the header, otherwise it is omitted.
final
methods List<String>
Configures the Access-Control-Allow-Methods CORS header. Expects a comma-delimited string (ex: 'GET,PUT,POST') or an array (ex: ['GET', 'PUT', 'POST']).
final
origin → dynamic
Configures the Access-Control-Allow-Origin CORS header. Possible values:
final
preflightContinue bool
If false, then the cors handler will terminate the response after performing its logic.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
successStatus int
The status code to be sent on successful OPTIONS requests, if preflightContinue is false.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited