I tried it on my project and I get "Method not allowed", which is the 405 error. What version of Laravel are you using?
Edit: And what happens if you post to another route that does not exist, do you get token mismatch or 405?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Lately, we've been seeing some DoS attacks on our applications that execute an empty POST on /, probably aimed at making a much sessions files as possible, making the server or account run out of disk space. There is no POST route for / on this application, so I'd expect Laravel to reply with a 405 status code. However, it gives a TokenMismatchException instead (because there is no _token).
After looking in to the code Laravel used to throw this exception, I understand why it is happening, but I haven't found out how to make it behave like I want it to. I don't know of a way to only throw the TokenMismatchException when a POST route is active, because the routes are not yet loaded.
I'd like to know if and how any of you solved this. Sending an empty POST to https://spark.laravel.com does seem to give me a 405 for example.
Please or to participate in this conversation.