APICORSConfig class
The CORS (Cross-Origin Resource Sharing) configuration of API responses.
Configured at cross_origin/api. See APICrossOriginConfig.
Constructors
- APICORSConfig({Object? allowOrigin, Object? allowMethods, Object? allowHeaders, bool? allowCredentials, Object? exposeHeaders, int? maxAge, bool? varyOrigin})
- APICORSConfig.fromJson(Map json)
-
factory
- APICORSConfig.resolve({APIConfig? apiConfig, ArgsSimple? args})
-
Resolves from the
cross_origin/apientry ofapiConfig, overridden by the command-line options inargs.factory
Properties
- allowCredentials → bool
-
The
Access-Control-Allow-Credentialsvalue.final -
allowHeaders
→ List<
String> -
The
Access-Control-Allow-Headersvalue. Empty omits the header. See localhostAllowHeaders.final -
allowMethods
→ List<
String> -
The
Access-Control-Allow-Methodsvalue. Empty omits the header.final -
allowOrigin
→ List<
String> -
The allowed origins (
Access-Control-Allow-Origin).final -
exposeHeaders
→ List<
String> -
The
Access-Control-Expose-Headersvalue. Empty omits the header.final - hashCode → int
-
The hash code for this object.
no setterinherited
- maxAge → int
-
The
Access-Control-Max-Agevalue, in seconds, allowing the browser to cache a preflight and skip anOPTIONSround-trip per cross-origin call. Only sent onOPTIONSresponses. Zero (the default) omits the header.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- varyOrigin → bool
-
If
true(the default) sendsVary: Origin.final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolveAllowHeaders(
String origin) → List< String> -
Resolves the
Access-Control-Allow-Headersvalue fororigin, appending localhostAllowHeaders for alocalhostorigin. -
resolveAllowOrigin(
String origin) → String? -
Resolves the
Access-Control-Allow-Originvalue fororigin, ornullwhenoriginis not allowed and no header should be sent. -
toJson(
) → Map< String, dynamic> -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
isLocalhostOrigin(
String origin) → bool -
Returns
trueiforiginis alocalhostorigin. -
normalizeOrigin(
String origin) → String -
Normalizes an
originfor comparison: lower-case and without a trailing/(added by APIServer.getOrigin when a request has noOriginheader). -
parseHeaderList(
Object? value, List< String> def) → List<String> -
Parses a header list
value, accepting a List or a comma separated String. Returnsdeffor anullvalue, and an empty list for an explicitly emptyvalue. -
parseMaxAge(
Object? value) → int? - Parses a maxAge value, accepting an int or a String.
Constants
-
defaultAllowHeaders
→ const List<
String> - The default value for allowHeaders.
-
defaultAllowMethods
→ const List<
String> - The default value for allowMethods.
-
defaultExposeHeaders
→ const List<
String> - The default value for exposeHeaders.
-
localhostAllowHeaders
→ const List<
String> -
Extra allowHeaders sent only to
localhostorigins: the Dart development server (webdev) sends anx-ijtheader.