CorsMiddleware class base
Middleware that applies Cross-Origin Resource Sharing (CORS) headers to outgoing responses.
This middleware:
- allows requests from any origin
- permits
GET,POST,PUT,DELETE, andOPTIONSmethods - allows the
Content-TypeandRangerequest headers - exposes
Content-LengthandContent-Rangeresponse headers - short-circuits preflight
OPTIONSrequests
This type is intended for use in route or global middleware pipelines.
Example:
await CorsMiddleware.middleware(request, () async {
request.response.write('OK');
});
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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
Static Methods
-
middleware(
HttpRequest request, Future< void> next()) → Future - Applies CORS headers to the response and handles preflight requests.