CorsConfig class

Configuration for Cross-Origin Resource Sharing (CORS).

CORS controls which domains can make cross-origin requests to the API. This is essential for web applications that access the API from different domains.

Example:

final config = CorsConfig(
  enabled: true,
  allowedOrigins: ['https://example.com', 'https://app.example.com'],
  allowedMethods: ['GET', 'POST', 'PUT'],
  allowCredentials: true,
);

Constructors

CorsConfig({bool enabled = false, List<String> allowedOrigins = const ['*'], List<String> allowedMethods = const ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'], List<String> allowedHeaders = const [], bool allowCredentials = false, int? maxAge, List<String> exposedHeaders = const []})
Creates a CORS configuration with the given settings.
const

Properties

allowCredentials bool
Whether credentials (cookies, authorization headers) are allowed.
final
allowedHeaders List<String>
List of allowed request headers.
final
allowedMethods List<String>
List of allowed HTTP methods for cross-origin requests.
final
allowedOrigins List<String>
List of allowed origin domains.
final
enabled bool
Whether CORS is enabled.
final
exposedHeaders List<String>
List of headers that browsers are allowed to access.
final
hashCode int
The hash code for this object.
no setterinherited
maxAge int?
Maximum time in seconds that preflight responses can be cached.
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