如果你曾经遇到过这个错误使用codeigniter 4与 AJAX 。**您请求的操作不被允许。**由于csrf保护。
CRITICAL - 2023-06-10 03:41:17 --> The action you requested is not allowed.
in SYSTEMPATH/Security/Security.php on line 306.
1 SYSTEMPATH/Security/Security.php(306): CodeIgniter\Security\Exceptions\SecurityException::forDisallowedAction()
2 SYSTEMPATH/Filters/CSRF.php(55): CodeIgniter\Security\Security->verify(Object(CodeIgniter\HTTP\IncomingRequest))
3 SYSTEMPATH/Filters/Filters.php(173): CodeIgniter\Filters\CSRF->before(Object(CodeIgniter\HTTP\IncomingRequest), null)
4 SYSTEMPATH/CodeIgniter.php(473): CodeIgniter\Filters\Filters->run('api/v1/notification/markasseen/4', 'before')
5 SYSTEMPATH/CodeIgniter.php(368): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false)
6 FCPATH/index.php(68): CodeIgniter\CodeIgniter->run()
检查下面的解决方案。我也面临着同样的问题,所以我决定帮助那些可能面临同样问题的人
1条答案
按热度按时间t3irkdon1#
最终解决方案
在Ajax中添加此代码