12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace App\Http\Middleware;
- use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
- use Closure;
- class VerifyCsrfToken extends Middleware
- {
- /**
- * Indicates whether the XSRF-TOKEN cookie should be set on the response.
- *
- * @var bool
- */
- protected $addHttpCookie = true;
- /**
- * The URIs that should be excluded from CSRF verification.
- *
- * @var array
- */
- protected $except = [
- //
- ];
- public function handle($request, Closure $next)
- {
- // 如果是来自 api 域名,就跳过检查
- $clientRoute = request()->route()->getName();
- if (!in_array($clientRoute, [ 'admin.oneImage','admin.specClass.add','admin.specClass.add_items','admin.good.save','service.login','service.check','service.reset']))
- {
- return parent::handle($request, $next);
- }
- return $next($request);
- }
- }
|