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

sdbruder's avatar

ngrok to homestead ok, but now I get a TokenMismatchException in VerifyCsrfToken.php line 53:

I've already created a ngrok tunnel to my laravel site in my local homestead, that worked ok, I've accessed from outside my site.

I've used:

ngrok http --host-header=mysite.app mysite.app:80

But now I'm getting TokenMismatchException in any form submissions that I'm trying (using locally I'm not having any problems, is obviously ngrok-induced).

0 likes
5 replies
duellsy's avatar

Did you ever find a solution to this? I'm having the same issue at the moment.

mezie's avatar

Did you add csrf_field to your form because by default Laravel will try to protrch from cross-site request forgery.

sdbruder's avatar

@duellsy: No, until now I've not found a way around it (the only solution I see is to turn off CSRF site-wide when I need remote access to homestead.

@mezie: Yes, I've added it, it works perfectly when I used it locally / directly, it only fails when via ngrok.

1 like
capsterx's avatar

The ngrok domain is in a list that most browsers honor to never store cookies that allow subdomain access (and none of the browsers I've used tells you this is why they ignore the cookies). So you need to store the cookie for X.ngrok.io instead of just .ngrok.io (which would be the default for most web apps)

Please or to participate in this conversation.