Commit 649ff9d3 by usualdesigner Committed by Qiang Xue

Allow to set Access-Control-Expose-Headers in Cors filter

parent f7cf3b50
......@@ -49,6 +49,8 @@ use yii\web\Response;
* 'Access-Control-Allow-Credentials' => true,
* // Allow OPTIONS caching
* 'Access-Control-Max-Age' => 3600,
* // Allow the X-Pagination-Current-Page header to be exposed to the browser.
* 'Access-Control-Expose-Headers' => ['X-Pagination-Current-Page'],
* ],
*
* ],
......@@ -82,6 +84,7 @@ class Cors extends ActionFilter
'Access-Control-Request-Headers' => ['*'],
'Access-Control-Allow-Credentials' => null,
'Access-Control-Max-Age' => 86400,
'Access-Control-Expose-Headers' => [],
];
......@@ -169,6 +172,10 @@ class Cors extends ActionFilter
$responseHeaders['Access-Control-Max-Age'] = $this->cors['Access-Control-Max-Age'];
}
if (isset($this->cors['Access-Control-Expose-Headers'])) {
$responseHeaders['Access-Control-Expose-Headers'] = implode(', ', $this->cors['Access-Control-Expose-Headers']);
}
return $responseHeaders;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment