Welcome to Hollywood...
This commit is contained in:
parent
5136420038
commit
d6d1153774
3 changed files with 7 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
# cors
|
||||
|
||||
![1.0.0-dev](https://img.shields.io/badge/version-1.0.0--dev-red.svg)
|
||||
![1.0.0-dev+1](https://img.shields.io/badge/version-1.0.0--dev+1-red.svg)
|
||||
![build status](https://travis-ci.org/angel-dart/cors.svg)
|
||||
|
||||
Angel CORS middleware.
|
||||
|
|
|
@ -42,9 +42,9 @@ RequestMiddleware cors([CorsOptions options]) {
|
|||
}
|
||||
|
||||
// Access-Control-Allow-Headers
|
||||
if (opts.allowedHeaders.isNotEmpty) {
|
||||
if (req.method == 'OPTIONS' && opts.allowedHeaders.isNotEmpty) {
|
||||
res.header('Access-Control-Allow-Headers', opts.allowedHeaders.join(','));
|
||||
} else {
|
||||
} else if (req.method == 'OPTIONS') {
|
||||
res.header('Access-Control-Allow-Headers',
|
||||
req.headers.value('Access-Control-Allow-Headers'));
|
||||
}
|
||||
|
@ -56,12 +56,12 @@ RequestMiddleware cors([CorsOptions options]) {
|
|||
}
|
||||
|
||||
// Access-Control-Allow-Methods
|
||||
if (opts.methods.isNotEmpty) {
|
||||
if (req.method == 'OPTIONS' && opts.methods.isNotEmpty) {
|
||||
res.header('Access-Control-Allow-Methods', opts.methods.join(','));
|
||||
}
|
||||
|
||||
// Access-Control-Max-Age
|
||||
if (opts.maxAge != null) {
|
||||
if (req.method == 'OPTIONS' && opts.maxAge != null) {
|
||||
res.header('Access-Control-Max-Age', opts.maxAge.toString());
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,6 @@ RequestMiddleware cors([CorsOptions options]) {
|
|||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return req.method != 'OPTIONS' || opts.preflightContinue;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ environment:
|
|||
sdk: ">=1.19.0"
|
||||
homepage: "https://github.com/angel-dart/cors.git"
|
||||
name: "angel_cors"
|
||||
version: "1.0.0-dev"
|
||||
version: "1.0.0-dev+1"
|
||||
dependencies:
|
||||
angel_framework: "^1.0.0-dev.28"
|
||||
dev_dependencies:
|
||||
|
|
Loading…
Reference in a new issue