Package Data | |
---|---|
Maintainer Username: | DivineOmega |
Package Create Date: | 2017-02-01 |
Package Last Update: | 2018-01-30 |
Home Page: | |
Language: | PHP |
License: | LGPL-3.0-only |
Last Refreshed: | 2024-11-17 03:03:21 |
Package Statistics | |
---|---|
Total Downloads: | 76 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 6 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Under certain conditions, when posting data from a form, the web server may lose the post data. This commonly happens if a user is uploading a large file beyond the size limits set in the web server's configuration.
Laravel does not handle this situation and may end up throwing a somewhat confusing TokenMismatchException in VerifyCsrfToken
due to CSRF protection.
The 'No Post Data Laravel Middleware' handles situations in which a post request has been submitted and contains no post data - a situation which should not occur under normal usage. By default, the middleware will redirect back to the previous page with an error message flashed to the session. This can then be output on your view as you would normally handle validation errors.
If needed, you can also modify this default behaviour and allow any code to run when the 'post request with no post data' situation is encountered.
composer require rapidwebltd/no-post-data-laravel-middleware
.RapidWeb\NoPostDataLaravelMiddleware\ServiceProvider::class,
to the providers
array in your config/app.php
file.\RapidWeb\NoPostDataLaravelMiddleware\Http\Middleware\NoPostData::class,
to the middleware
array in your app/Http/Kernel.php
file.
This must be added after \Illuminate\View\Middleware\ShareErrorsFromSession::class,
and before \App\Http\Middleware\VerifyCsrfToken::class,
.php artisan vendor:publish
.errorMessage
variable in your newly published config/nopostdata.php
file.closure
variable found in the config/nopostdata.php
file.