Skip to content

Commit e386454

Browse files
committed
2.8.3 - fixed #156
1 parent c8a5919 commit e386454

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release Notes for Element API
22

3+
## 2.8.3 - 2021-09-25
4+
5+
### Fixed
6+
- Fixed a bug where endpoint callables weren’t getting called for `OPTIONS` requests. ([#156](https://github.com/craftcms/element-api/issues/156))
7+
38
## 2.8.2 - 2021-09-03
49

510
### Fixed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "craftcms/element-api",
33
"description": "Create a JSON API for your elements in Craft",
4-
"version": "2.8.2",
4+
"version": "2.8.3",
55
"type": "craft-plugin",
66
"keywords": [
77
"api",

src/controllers/DefaultController.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ class DefaultController extends Controller
5656
*/
5757
public function actionIndex(string $pattern): Response
5858
{
59-
if ($this->request->getIsOptions()) {
60-
$this->response->format = Response::FORMAT_RAW;
61-
return $this->response;
62-
}
63-
6459
$callback = null;
6560
$jsonOptions = null;
6661
$pretty = false;
@@ -79,6 +74,12 @@ public function actionIndex(string $pattern): Response
7974
$config = $this->_callWithParams($config, $params);
8075
}
8176

77+
if ($this->request->getIsOptions()) {
78+
// Now that the endpoint has had a chance to add CORS response headers, end the request
79+
$this->response->format = Response::FORMAT_RAW;
80+
return $this->response;
81+
}
82+
8283
if (is_array($config)) {
8384
// Merge in the defaults
8485
$config = array_merge($plugin->getDefaultResourceAdapterConfig(), $config);

0 commit comments

Comments
 (0)