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

karthik_dev's avatar

POST http://localhost:8000/users 500 (Internal Server Error)

I'm using reactjs for frontend and laravel for backend.when i dispatch the axios post in the react-redux app,i get the above error.when i checked the route in the postman,the route http://localhost:8000/users produces TokenMismatchException in VerifyCsrfToken.php line 67.Please help me out.

0 likes
9 replies
andreasbakir's avatar

add this tag to your head

<meta name="csrf-token" content="{{ csrf_token() }}">
tykus's avatar

The error will be different in Postman because you are not using the framework, or React app to send the request; so this is likely a false positive.

If you have a 500 error, you should be able to get more information from the Response part of the Network tab in your browsers dev tools.

1 like
karthik_dev's avatar

Cant able to figure out whats exactly happening.Here is the response part

Response Headers: Access-Control-Allow-Origin:http://localhost:8082 Cache-Control:no-cache, private Connection:close Content-Type:text/html; charset=UTF-8 Date:Mon, 16 Oct 2017 12:23:03 +0000 Date:Mon, 16 Oct 2017 12:23:03 GMT Host:localhost:8000 Set-Cookie:laravel_session=eyJpdiI6IkhVd3h2em4zV3RVRExlRVc2bE15ckE9PSIsInZhbHVlIjoiTVVCeVlGUjR5ZjM0NHFcL0dGb2Q4T0xZbk9UTGRVSTczaHExaTlSVFwvSUpKSERPUXk2bDkrQTJ4NXZyNzIzTUtTYTY0YTdqUkVqS1RrWWhqc0g5RDU2QT09IiwibWFjIjoiYTBhMTBmM2U0NzQ4MGM0OTk2Y2YxYWU3NzY5ZjNhMjBkMTcyOTMyNGJlOGRkNGIwMGUxYTY5MTY2YjM3NDExMSJ9; expires=Mon, 16-Oct-2017 14:23:03 GMT; Max-Age=7200; path=/; HttpOnly Vary:Origin X-Powered-By:PHP/7.1.6

Request Header: Accept:application/json, text/plain, / Accept-Encoding:gzip, deflate, br Accept-Language:en-GB,en-US;q=0.8,en;q=0.6 Cache-Control:no-cache Connection:keep-alive Content-Length:169 Content-Type:application/json;charset=UTF-8 Host:localhost:8000 Origin:http://localhost:8082 Pragma:no-cache Referer:http://localhost:8082/SignupForm User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

my laravel app is running on port 8000 and the react app is running on 8080.Is this an issue related to CORS .

karthik_dev's avatar

It works only when i comment the \App\Http\Middleware\VerifyCsrfToken::class in the kernel.php.Please help me out.thanks in advance.

RamjithAp's avatar

Add this line in your verifycsrftoken middleware file - protected $except = [ 'users/*' ];

ejdelmonico's avatar

after adding the service provider, did you go to app/Http/Kernel.php and add:

protected $middleware = [
    // ...
    \Barryvdh\Cors\HandleCors::class,
];

and then run php artisan vendor:publish --provider="Barryvdh\Cors\ServiceProvider"

Please or to participate in this conversation.