Cors constructor
Cors({})
Allows origins, with the usual defaults for everything else.
Implementation
Cors({
this.origins = const AllowedOrigins.any(),
this.methods = const {'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'},
this.headers = const {'accept', 'authorization', 'content-type'},
this.exposeHeaders = const {},
this.credentials = false,
this.maxAge,
}) {
if (credentials && origins.headerFor('https://example.test') == '*') {
throw ArgumentError(
'CORS credentials cannot be used with AllowedOrigins.any(): a browser '
'refuses a credentialed response whose allowed origin is "*". Name the '
'origins with AllowedOrigins.only or .matching instead.',
);
}
}