Ssionn's avatar

Sanctum CSRF Cookie, how to add token in form?

I have a csrf-token mismatch. Now I haven't really used sanctum before, so I'm trying to get some insight on how to proceed when I hit the endpoint '/sanctum/csrf-cookie'. How do I add the csrf token to my form?

0 likes
2 replies
JussiMannisto's avatar
Level 50

You don't need to add it manually, but you have to configure Sanctum and Axios.

First things first: will your front and back ends run on the same domain, or are they subdomains of the same domain, e.g. api.app.com and app.com?

Ssionn's avatar

@JussiMannisto Yeah, i've fixed the problem, the problem was that I was running the project on Herd, so it automatically expected the {{ project }}.test domain. So after fixing the env variable, it worked.

Please or to participate in this conversation.