app.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. use App\Http\Middleware\EncryptCookies;
  3. use Illuminate\Console\Scheduling\Schedule;
  4. use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncryptCookies;
  5. use Illuminate\Foundation\Application;
  6. use Illuminate\Foundation\Configuration\Exceptions;
  7. use Illuminate\Foundation\Configuration\Middleware;
  8. use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
  9. use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance;
  10. use Webkul\Core\Http\Middleware\SecureHeaders;
  11. use Webkul\Installer\Http\Middleware\CanInstall;
  12. return Application::configure(basePath: dirname(__DIR__))
  13. ->withRouting(
  14. web: __DIR__.'/../routes/web.php',
  15. commands: __DIR__.'/../routes/console.php',
  16. health: '/up',
  17. )
  18. ->withMiddleware(function (Middleware $middleware) {
  19. /**
  20. * Remove the default Laravel middleware that prevents requests during maintenance mode. There are three
  21. * middlewares in the shop that need to be loaded before this middleware. Therefore, we need to remove this
  22. * middleware from the list and add the overridden middleware at the end of the list.
  23. *
  24. * As of now, this has been added in the Admin and Shop providers. I will look for a better approach in Laravel 11 for this.
  25. */
  26. $middleware->remove(PreventRequestsDuringMaintenance::class);
  27. /**
  28. * Remove the default Laravel middleware that converts empty strings to null. First, handle all nullable cases,
  29. * then remove this line.
  30. */
  31. $middleware->remove(ConvertEmptyStringsToNull::class);
  32. $middleware->append(SecureHeaders::class);
  33. $middleware->append(CanInstall::class);
  34. /**
  35. * Add the overridden middleware at the end of the list.
  36. */
  37. $middleware->replaceInGroup('web', BaseEncryptCookies::class, EncryptCookies::class);
  38. $middleware->trustProxies('*');
  39. })
  40. ->withSchedule(function (Schedule $schedule) {
  41. //
  42. })
  43. ->withExceptions(function (Exceptions $exceptions) {
  44. //
  45. })->create();