bug fixing

This commit is contained in:
Roland Schneider 2021-09-28 19:20:21 +02:00
parent 98c5cf86be
commit 2fdad33a40
2 changed files with 10 additions and 8 deletions

View File

@ -29,16 +29,8 @@ class LoginController extends Controller
'cors' => [ 'cors' => [
// restrict access to // restrict access to
'Origin' => ['https://botondfitness.hu'], 'Origin' => ['https://botondfitness.hu'],
// Allow only POST and PUT methods
// 'Access-Control-Request-Method' => ['POST', 'PUT'],
// Allow only headers 'X-Wsse'
// 'Access-Control-Request-Headers' => ['X-Wsse'],
// Allow credentials (cookies, authorization headers, etc.) to be exposed to the browser // Allow credentials (cookies, authorization headers, etc.) to be exposed to the browser
'Access-Control-Allow-Credentials' => true, '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'],
] ]
]; ];
return $behaviors; return $behaviors;

View File

@ -9,6 +9,7 @@ use Lcobucci\JWT\Token;
use sizeg\jwt\JwtHttpBearerAuth; use sizeg\jwt\JwtHttpBearerAuth;
use Yii; use Yii;
use yii\filters\auth\AuthMethod; use yii\filters\auth\AuthMethod;
use yii\filters\Cors;
use yii\rest\Controller; use yii\rest\Controller;
class RestController extends Controller class RestController extends Controller
@ -22,6 +23,15 @@ class RestController extends Controller
'auth' => [$this, 'auth'], 'auth' => [$this, 'auth'],
'optional' => $this->getOptionalActions(), 'optional' => $this->getOptionalActions(),
]; ];
$behaviors['corsFilter'] = [
'class' => Cors::class,
'cors' => [
// restrict access to
'Origin' => ['https://botondfitness.hu'],
// Allow credentials (cookies, authorization headers, etc.) to be exposed to the browser
'Access-Control-Allow-Credentials' => true,
]
];
return $behaviors; return $behaviors;
} }