Hi @nobisnews ,
you should use this: https://laravel.com/docs/5.2/routing#csrf-x-csrf-token and you are fine.
Ben
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello everyone,
I'm using React.js as my frontend framework, and Laravel as a pretty much separate backend API (following https://github.com/sexyoung/laravel-react-webpack). I can send GET requests to my backend Laravel API, but when it comes to ajax POST requests, I get the TokenMismatchError.
This is understandable since I don't provide the XSRF token in the header of my ajax request, but I was wondering how to get the XSRF token key in React. Since I'm not using Blade templating, I can't just use {{ csrf_token() }}. Any one have similar problems, or any suggestions? Thanks.
Please or to participate in this conversation.