ajax - cakephp 4 为特定操作禁用 csrf
问题描述
我在 cakephp4 项目上工作,
希望允许一个动作从没有 csrf 的任何客户端获取发布请求。
根据文档,我编写了以下代码,但它在发布请求时显示 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;
}
}
解决方案
推荐阅读
- discord - 公会最高角色指挥部?
- matlab - Problems with step size Simulink
- java - 渲染和眼空间错位导致不精确的光线投射
- javascript - 如何发现现有“搜索”按钮后面的 URL / 字符串?
- javascript - 延迟将显示更改为无
- batch-file - 如何从批处理中仅签入 TFS 中的特定分支?
- java - 我收到应用程序构建错误,资源“attr/arc_position”的重复值与配置“”
- android - 如何使用 androguard 或 aapt 从 .apk 中提取过滤器意图?
- javascript - JavaScript 'myFunction' 不是一个函数,尽管它是
- flutter - 如何在不同类的迭代器 FOR 中传递变量列表?