File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ This package can be used as a library. You can use it in your framework using:
33
33
| allowedOrigins | Matches the request origin. | ` [] ` |
34
34
| allowedOriginsPatterns | Matches the request origin with ` preg_match ` . | ` [] ` |
35
35
| allowedHeaders | Sets the Access-Control-Allow-Headers response header. | ` [] ` |
36
- | exposedHeaders | Sets the Access-Control-Expose-Headers response header. | ` false ` |
37
- | maxAge | Sets the Access-Control-Max-Age response header. | ` false ` |
36
+ | exposedHeaders | Sets the Access-Control-Expose-Headers response header. | ` [] ` |
37
+ | maxAge | Sets the Access-Control-Max-Age response header. | ` 0 ` |
38
38
| supportsCredentials | Sets the Access-Control-Allow-Credentials header. | ` false ` |
39
39
40
40
The _ allowedMethods_ and _ allowedHeaders_ options are case-insensitive.
Original file line number Diff line number Diff line change @@ -55,11 +55,18 @@ private function normalizeOptions(array $options = []): array
55
55
'maxAge ' => 0 ,
56
56
];
57
57
58
- if ($ options ['exposedHeaders ' ] && ! is_array ( $ options [ ' exposedHeaders ' ]) ) {
59
- throw new InvalidOptionException ( " CORS option ` exposedHeaders` should be `false` or an array " ) ;
58
+ if ($ options ['exposedHeaders ' ] === false ) {
59
+ $ options [ ' exposedHeaders ' ] = [] ;
60
60
}
61
61
62
- foreach (['allowedOrigins ' , 'allowedOriginsPatterns ' , 'allowedHeaders ' , 'allowedMethods ' ] as $ key ) {
62
+ $ arrayHeaders = [
63
+ 'allowedOrigins ' ,
64
+ 'allowedOriginsPatterns ' ,
65
+ 'allowedHeaders ' ,
66
+ 'allowedMethods ' ,
67
+ 'exposedHeaders ' ,
68
+ ];
69
+ foreach ($ arrayHeaders as $ key ) {
63
70
if (!is_array ($ options [$ key ])) {
64
71
throw new InvalidOptionException ("CORS option ` {$ key }` should be an array " );
65
72
}
You can’t perform that action at this time.
0 commit comments