我有一個starter laravel應用程式,當我訪問登錄頁面時,顯示 "這個頁面現在不作業",我在代碼中沒有看到任何錯誤。
我的loginController:
<?php
namespace AppHttpControllersAuth。
使用 AppHttpControllersController。
使用 IlluminateHttpRequest。
class LoginController extends Controller
{
public function __construct()。
{
$this->middleware(['auth'])。
}
public function index(){
return view('auth.login')。
}
public function store(Request $request){
dd($request-> remember);
$this->validate($request, [
'email' => 'required|email',
'password' => 'required',
]);
if(!auth()-> attempt($request->only('email', 'password')){
return back()->with('status', 'Invalid login details') 。
}
return redirect()->route('dashboard') 。
}
}
登錄路線在web.php檔案中 :
Route::get('/login', [LoginController::class, 'index'])-> name('login') 。
Route::post('/login', [LoginController::class, 'store'])。)
在ENV檔案中的重要設定:
APP_DEBUG=true
APP_ENV=local
應用除錯在config/app.php
'debug' => (bool) env('APP_DEBUG', true)。
我試過 :
1
清空機會
> php artisan config:cache
> php artisan config:clear
2
我通過以下方式重啟了應用程式:
> php artisan down
然后在幾秒鐘內
> php artisan up
"確保在你的環境配置中沒有空格,如果你有一個帶有空格的值,確保用引號("")將其括起來。" - @Dexter Bengil
-我確定
額外資訊:
。應用程式中沒有使用cookies
。
我試圖訪問的鏈接。http://l.v/login
PHP版本。PHP 7.4.0
C:laravel>php artisan --version
Laravel框架8.61.0。
如果我在問題中包含太多的資訊,我很抱歉,如果你需要任何資訊,請告訴我。
uj5u.com熱心網友回復:
我認為你需要洗掉這些行:
public function __construct()
{
$this->middleware(['auth'])。
}
因為你強制要求使用auth中間件。 你不應該在登錄頁面中添加 auth 中間件。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/329334.html
標籤:

