当我尝试去时 http://mysite/logout
,我得到
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
No message
路线:
Auth::routes();
php artisan route:list
的一部分+-----------+-------------------------+---------------------+------------------------------------------------------------------------+--------------+
| Method | URI | Name | Action | Middleware |
+-----------+-------------------------+---------------------+------------------------------------------------------------------------+--------------+
| POST | logout | logout | App\Http\Controllers\Auth\LoginController@logout | web |
当我使用这个默认按钮时
<a href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
Logout
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
一切都好。
编辑:添加了我自己的答案。
最佳答案
Route::get('logout', 'Auth\LoginController@logout', function () {
return abort(404);
});
那对我有用。
关于php - 注销错误 Laravel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48417762/