Пытаюсь загрузить картинку на сервер он выдает ошибки
Error
Access to fetch at '
test/api/photo' from origin '
localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
POST
test/api/photo net::ERR_FAILED
Uncaught (in promise) TypeError: Failed to fetch
Не понимаю как отключить его
Вот мой behaviors
public function behaviors()
{
$behaviors = parent::behaviors();
$auth = $behaviors['authenticator'];
unset($behaviors['authenticator']);
$behaviors['corsFilter'] = [
'class' => \yii\filters\Cors::className(),
'cors' => [
'Access-Control-Allow-Origin' => ['*'],
'Access-Control-Request-Method' => ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'],
'Access-Control-Request-Headers' => ['*'],
'Access-Control-Allow-Credentials' => true,
'Access-Control-Max-Age' => 86400,
'Access-Control-Expose-Headers' => [],
]
];
$behaviors['authenticator'] = [
'class' => \app\filters\BearerAuth::className(),
];
$behaviors['authenticator']['except'] = ['options'];
return $behaviors;
}
Если надо то вот полный код
https://github.com/VKaysarov/REST-API-WorldSkills-
Что интересно у UserConroller получилось так отключить CORS