|
@@ -3,6 +3,8 @@
|
|
|
use Illuminate\Foundation\Application;
|
|
use Illuminate\Foundation\Application;
|
|
|
use Illuminate\Foundation\Configuration\Exceptions;
|
|
use Illuminate\Foundation\Configuration\Exceptions;
|
|
|
use Illuminate\Foundation\Configuration\Middleware;
|
|
use Illuminate\Foundation\Configuration\Middleware;
|
|
|
|
|
+use Illuminate\Http\Exceptions\PostTooLargeException;
|
|
|
|
|
+use Illuminate\Http\Request;
|
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
|
use App\Http\Middleware\SetUserLanguage;
|
|
use App\Http\Middleware\SetUserLanguage;
|
|
|
use App\Http\Middleware\CheckPermission;
|
|
use App\Http\Middleware\CheckPermission;
|
|
@@ -30,6 +32,18 @@ return Application::configure(basePath: dirname(__DIR__))
|
|
|
$schedule->call(new DeleteExpiredTokens)->everyMinute();
|
|
$schedule->call(new DeleteExpiredTokens)->everyMinute();
|
|
|
})
|
|
})
|
|
|
->withExceptions(function (Exceptions $exceptions) {
|
|
->withExceptions(function (Exceptions $exceptions) {
|
|
|
- //
|
|
|
|
|
|
|
+ // Anexo maior que o post_max_size do PHP: responde em JSON no lugar do
|
|
|
|
|
+ // erro cru, para o front conseguir mostrar a mensagem ao usuário.
|
|
|
|
|
+ $exceptions->render(function (PostTooLargeException $e, Request $request) {
|
|
|
|
|
+ if (!$request->expectsJson()) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return response()->json([
|
|
|
|
|
+ 'message' => __('http.payload_too_large', [
|
|
|
|
|
+ 'max' => round(config('uploads.max_size_kb') / 1024, 1),
|
|
|
|
|
+ ]),
|
|
|
|
|
+ ], 413);
|
|
|
|
|
+ });
|
|
|
})
|
|
})
|
|
|
->create();
|
|
->create();
|