CodeIgniter Forums
CI 4.5.1 CSRF - The action you requested is not allowed. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: CI 4.5.1 CSRF - The action you requested is not allowed. (/showthread.php?tid=90725)



CI 4.5.1 CSRF - The action you requested is not allowed. - jackvaughn03 - 04-23-2024

Hello experts,

Has anyone encountered the same issue as mine after updating from CI4.4.5 to CI4.5.1? 
Submitting a form with CSRF configuration previously posed no problem.
However, now I can't submit the form using ajax unless I configure it as expected in the filter. 
I need some routes to not be excepted in the filter (csrf->except->[]) configuration.

Thank you in advance.


[Image: Screenshot-2024-04-24-130236.png]


RE: CI 4.5.1 CSRF - The action you requested is not allowed. - BhambriRohunu - 04-24-2024

Hey there,

Yes, CI 4.5.1 tightened CSRF handling. To exclude routes, use csrf_exclude() in your controller:

PHP
$this->protectExcept(['route1', 'route2']);

This allows AJAX form submissions without CSRF validation on those routes.


RE: CI 4.5.1 CSRF - The action you requested is not allowed. - kenjis - 04-25-2024

@BhambriRohunu Excuese me, are you a bot? Your comment is nonsense.