CorsPolicy class

Describes the Cross-Origin Resource Sharing (CORS) policy, for a given service. Refer to CORS for further details about cross origin resource sharing. For example, the following rule restricts cross origin requests to those originating from example.com domain using HTTP POST/GET, and sets the Access-Control-Allow-Credentials header to false. In addition, it only exposes X-Foo-bar header and sets an expiry period of 1 day.

Constructors

CorsPolicy({List<StringMatch>? allowOrigins, List<String>? allowMethods, List<String>? allowHeaders, List<String>? exposeHeaders, Duration? maxAge, bool? allowCredentials})
The main constructor.
const
CorsPolicy.fromJson(Map<String, dynamic> json)
Creates a CorsPolicy from JSON data.

Properties

allowCredentials bool?
Indicates whether the caller is allowed to send the actual request (not the preflight) using credentials. Translates to Access-Control-Allow-Credentials header.
final
allowHeaders List<String>?
List of HTTP headers that can be used when requesting the resource. Serialized to Access-Control-Allow-Headers header.
final
allowMethods List<String>?
List of HTTP methods allowed to access the resource. The content will be serialized into the Access-Control-Allow-Methods header.
final
allowOrigins List<StringMatch>?
String patterns that match allowed origins. An origin is allowed if any of the string matchers match. If a match is found, then the outgoing Access-Control-Allow-Origin would be set to the origin as provided by the client.
final
exposeHeaders List<String>?
A list of HTTP headers that the browsers are allowed to access. Serialized into Access-Control-Expose-Headers header.
final
hashCode int
The hash code for this object.
no setterinherited
maxAge Duration?
Specifies how long the results of a preflight request can be cached. Translates to the Access-Control-Max-Age header.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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