简体   繁体   中英

Laravel Random Verify CSRF Token

I currently have a web application in the process of being built in Laravel 5.3.

I have it running locally on my MacBook Pro using Laravel Valet with a SQL Server. All intended functionality works.

I then uploaded it up to my Ubuntu web server on DigitalOcean and have had it up there ever since I started this project ( 8 months ago ) without any issues.

For a specific form POST Request I am receiving a Token Mismatch Error:

TokenMismatchException in VerifyCsrfToken.php line 68

The user is already logged in and other POST Requests on the application work. The form has the correct CSRF Token inside of the form and has the token stored in the head of the page under a meta tag ( ).

I am not having this issue locally and they both have the same Database Schema and Content.

I fail to understand why this issue would only happen on the web server.

Any help is much appreciated.

Based on my assumption: Make sure that you are added $this->middleware('auth'); into the constructor of your controller which handle that post request.

Also try with use below one of the csrf token field option:

<input type="hidden" name="_token" value="{{ csrf_token() }}">

Or:

{{ csrf_field() }}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM