我正在研究 cakephp4 项目
希望允许一个动作从没有 csrf 的任何客户端获取 post 请求。
根据 documentation,我编写了以下代码,但在发布请求时显示 BAD REQUEST。
class MylogsController extends AppController
{
public function initialize(): void
{
parent::initialize();
$this->loadComponent('Security');
}
public function beforeFilter(EventInterface $event)
{
parent::beforeFilter($event);
$this->Security->setConfig('unlockedActions', ['add']);
}
public function add()
{
debug($this->request->getData());exit;
}
}