Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

swen's avatar
Level 1

[L5] TokenMismatchException on post to a route

Hi there,

I hope someone can help me resolve the following problem. I need a route that i can post to from a remote host. I have not enabled the VerifyCsrfToken middleware on the route that is throwing the exception.

Here is my controller

class PiController extends Controller {

    /**
     * @Post("raspberries", as="raspberries_path")
     */
    public function raspberries()
    {
        header("Access-Control-Allow-Origin: *");
        header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
        dd('blah');
    }
}
0 likes
3 replies
RlyDontKnow's avatar
Level 1

In App\Http\Kernel.php comment out this part 'App\Http\Middleware\VerifyCsrfToken'.

Please or to participate in this conversation.