CSRF is very wierd, I often get this error on my website. The simplest solution is make a new route to return CSRF token. When server return with CSRF token error, get a new token from server and replace the old one
Ajax calls flood causes TokenMismatchException
Hi everyone,
I am using Laravel 5.
I have a calculator feature on my site, which makes many AJAX calls to a route (via POST) and as you know CSRF is enabled for all routes by default, which is nice. But the problem is that if I try to flood it (make it generate like 100-200 requests) then it starts to throw a TokenMismatchException. I am passing the _token value properly. It normally works, excluding the cases when you try to flood it.
I am afraid that this behavior could occur for a regular user and then the calculator will stop working. I am not sure why it happens. Could you please explain and give me an idea for solving it?
The easiest way is to turn CSRF off for this particular route, but I am sure there must be a better solution to this. Thanks!
Please or to participate in this conversation.