yii2: Regression: Cors::beforeAction()
There’s a regression in 2.0.14-dev Cors::beforeAction()
after merge: https://github.com/yiisoft/yii2/commit/399dbce0cadbd7631f726841ece3ecf6a830444d
This is my test in Codeception:
public function preflight(ApiTester $I): void
{
$I->haveHttpHeader('Access-Control-Request-Headers', 'Content-Type');
$I->haveHttpHeader('Access-Control-Request-Method', 'POST');
$I->haveHttpHeader('Accept', '*/*');
$I->sendOPTIONS('/users');
$I->seeResponseCodeIs(200);
$I->seeHttpHeader('Content-Type', 'application/vnd.api+json; charset=UTF-8');
$I->seeHttpHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS');
$I->seeHttpHeader('Access-Control-Allow-Headers', 'Content-Type');
}
Before merge https://github.com/yiisoft/yii2/commit/399dbce0cadbd7631f726841ece3ecf6a830444d:
See http header "Content-Type","application/vnd.api+json; charset=UTF-8"
- Expected | + Actual
@@ @@
-'application/vnd.api+json; charset=UTF-8'
+'application/vnd.api+json; charset=UTF-8'
After merge https://github.com/yiisoft/yii2/commit/399dbce0cadbd7631f726841ece3ecf6a830444d:
See http header "Content-Type","application/vnd.api+json; charset=UTF-8"
- Expected | + Actual
@@ @@
-'application/vnd.api+json; charset=UTF-8'
+'text/html; charset=UTF-8'
Additional info
Q | A |
---|---|
Yii version | 2.0.14-dev |
PHP version | 7.1.4 |
Operating system | macOS High Sierra 10.13.3 |
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 55 (33 by maintainers)
If so, moving to 2.0.15 to think if it can be done better.
@samdark, what do you think about it Preflighted requests (see example of preflight request/response)? And about this https://github.com/yiisoft/yii2/issues/15665#issuecomment-367489876. We already have the
actionOptions
method in theActiveController
class. The headers of this action are never included in the response if you use the CORS filter.https://github.com/yiisoft/yii2/blob/77ad6bc00847d4964a0b2a82d3b70dcd7cb5a1cf/framework/rest/ActiveController.php#L102-L104 https://github.com/yiisoft/yii2/blob/77ad6bc00847d4964a0b2a82d3b70dcd7cb5a1cf/framework/rest/OptionsAction.php#L32-L44
The front-end application is working. But the response from the API was significantly reduced, which does not give a full submission of the resource.
You’re confusing request and response. See response example there:
According to W3C spec,
Cache-Control: no-cache
,Pragma: no-cache
andDate
are ignored and aren’t cached on clients so it comes to:What exactly happened to Ember.js 3.0 app when we started to send these reduced CORS responses? Did it break somehow? How exactly?
I see. So there’s no error per se and it’s overall just confusing, right?