会话在 Laravel 包开发中过期

Session Expired in Laravel Package Development

说明 我在将插入 laravel 项目的 laravel 包中使用 livewire。我成功地将 Livewire 集成到我的包中。我正在获取的错误是当我单击绑定到组件方法的按钮时,由于不活动,此页面已过期。 我在我的基本文件中添加了 csrf 令牌,如

<meta name="csrf-token" content="{{ csrf_token() }}" />

重现的确切步骤

public function render(){ 
    return view('acc::livewire.voucher-component')->layout('acc::layouts.app'); 
   }

精简、可复制粘贴的代码片段 依赖项

    "php": "^7.3|^8.0",
    "illuminate/support": "^8.15",
    "livewire/livewire": "^2.3",
    "fruitcake/laravel-cors": "^2.0"

浏览器:[Chrome,]

包路由文件

    <?php

use Enam\Acc\Http\Livewire\AccHeadComponent;
use Enam\Acc\Http\Livewire\VoucherComponent;
use Illuminate\Support\Facades\Route;

use Enam\Acc\Http\Controllers\HomeController;

Route::get('/acc', function () {
    return view('acc::app');
});
Route::get('/acc/test', VoucherComponent::class);

尝试将 web 中间件应用于路由


use Enam\Acc\Http\Livewire\AccHeadComponent; 
use Enam\Acc\Http\Livewire\VoucherComponent; 
use Illuminate\Support\Facades\Route; 
use Enam\Acc\Http\Controllers\HomeController; 

Route::middleware(['web'])
->group(function() {
    Route::get('/acc', function () { return view('acc::app'); }); 
    Route::get('/acc/voucher-entry', 'Enam\Acc\Http\Controllers\HomeController@index'); 
    Route::get('/acc/test', VoucherComponent::class);
});