I have a backend project on my ssl server, like ssl.mybackend.com, with following:
class FormController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['index', 'delete', 'view', 'create'],
'allow' => true,
'roles' => ['@'], //only authorized users
],
[
'actions'=> ['create-order'],
'allow'=>true //change all users to "myfrontend.com"
]
],
],
];
}
I need to grant an access to create-order action only to my frontend website.
I am not sure if it's possible to do with AccessControl and appreciate if you could advise other solutions.
If you want to use ajax calls from frontend on another domain, you should use
corsFilterinstead. Example from documentation:Cross Origin Resource Sharing in Yii2