VerifyCsrfToken.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
  4. use Closure;
  5. class VerifyCsrfToken extends BaseVerifier
  6. {
  7. /**
  8. * The URIs that should be excluded from CSRF verification.
  9. *
  10. * @var array
  11. */
  12. protected $except = [
  13. //
  14. "wechat",
  15. "notify",
  16. "admin/Base/Attachment/*",
  17. '/web/notify-account'
  18. ];
  19. public function handle($request, Closure $next)
  20. {
  21. // 如果是来自 api 域名,就跳过检查
  22. $QUERY_STRING = explode('/', $_SERVER['QUERY_STRING']);
  23. // dd($QUERY_STRING);die;
  24. if($QUERY_STRING[0] == 'route=admin' && $QUERY_STRING[1] == 'Base' && $QUERY_STRING[2] == 'Attachment'){
  25. return $next($request);
  26. }
  27. if($QUERY_STRING[0] == 'route=wechat'){
  28. return $next($request);
  29. }
  30. if($QUERY_STRING[0] == 'route=Api'){
  31. return $next($request);
  32. }
  33. if($QUERY_STRING[0] == 'route=notify'){
  34. return $next($request);
  35. }
  36. return parent::handle($request, $next);
  37. }
  38. }