Reputation: 23
Description I am using livewire in a laravel package that will plug into a laravel project. I succefully integrated Livewire in my package. The error i am fetching is This page has expired due to inactivty when i click a button that is binded to a component method. I added csrf token in my base file like
<meta name="csrf-token" content="{{ csrf_token() }}" />
Exact steps to reproduce
Route::get('/acc/test'VoucherComponent::class);
public function render(){
return view('acc::livewire.voucher-component')->layout('acc::layouts.app');
}
Stripped-down, copy-pastable code snippets Dependencies
"php": "^7.3|^8.0",
"illuminate/support": "^8.15",
"livewire/livewire": "^2.3",
"fruitcake/laravel-cors": "^2.0"
Browser: [ Chrome,]
Packages Route File
<?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);
Upvotes: 2
Views: 1565
Reputation: 12835
Try applying web
middleware to the routes
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);
});
Upvotes: 5