目标 class [App\\Http\\EnsureFrontendRequestsAreStateful] 不存在
Target class [App\\Http\\EnsureFrontendRequestsAreStateful] does not exist
我正在使用 Laravel Sanctum 通过 laravel API 后端对 React SPA 进行身份验证。
当我尝试访问不需要身份验证的路由时,出现此错误:
“目标 class [App\Http\EnsureFrontendRequestsAreStateful] 不存在。”
我应该怎么做才能只守卫一些路线,而让其他路线开放。
这通常可以通过以下方式解决:composer dump-autoload
您可以详细了解该命令的作用here
composer dump-autoload won’t download a thing. It just regenerates the list of all classes that need to be included in the project (autoload_classmap.php). Ideal for when you have a new class inside your project.
您可能缺少 app/Http/Kernel.php
文件中的导入。
// app/Http/Kernel.php
<?php
namespace App\Http;
use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;
我正在使用 Laravel Sanctum 通过 laravel API 后端对 React SPA 进行身份验证。
当我尝试访问不需要身份验证的路由时,出现此错误:
“目标 class [App\Http\EnsureFrontendRequestsAreStateful] 不存在。”
我应该怎么做才能只守卫一些路线,而让其他路线开放。
这通常可以通过以下方式解决:composer dump-autoload
您可以详细了解该命令的作用here
composer dump-autoload won’t download a thing. It just regenerates the list of all classes that need to be included in the project (autoload_classmap.php). Ideal for when you have a new class inside your project.
您可能缺少 app/Http/Kernel.php
文件中的导入。
// app/Http/Kernel.php
<?php
namespace App\Http;
use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;