VerifyCsrfToken.php 930 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
  4. use Closure;
  5. class VerifyCsrfToken extends Middleware
  6. {
  7. /**
  8. * Indicates whether the XSRF-TOKEN cookie should be set on the response.
  9. *
  10. * @var bool
  11. */
  12. protected $addHttpCookie = true;
  13. /**
  14. * The URIs that should be excluded from CSRF verification.
  15. *
  16. * @var array
  17. */
  18. protected $except = [
  19. //
  20. ];
  21. public function handle($request, Closure $next)
  22. {
  23. // 如果是来自 api 域名,就跳过检查
  24. $clientRoute = request()->route()->getName();
  25. if (!in_array($clientRoute, [ 'admin.oneImage','admin.specClass.add','admin.specClass.add_items','admin.good.save','service.login','service.check','service.reset']))
  26. {
  27. return parent::handle($request, $next);
  28. }
  29. return $next($request);
  30. }
  31. }