Laravel 即使凭据错误,页面也会过期

Laravel Page Expired even with wrong credentials

我有一个 Laravel 项目,其中包含一个登录论坛。 在本地机器上一切正常,但在上传到实时服务器后,一旦用户尝试登录,它最终会出现一个页面(页面已过期)。 请注意,尽管凭据正确或错误,但结果相同!

更新:尝试注册新用户时,会发生同样的问题。并且用户未添加到数据库中。

我尝试了所有可能的建议。 这是我的 .env

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:LJ+nS01CLhF0Vkq5f4srIvC0zCu9Y3Yh31YP5TLD9aw=
APP_DEBUG=true
APP_URL=http://test.net

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test_website.v4
DB_USERNAME=test_root
DB_PASSWORD=root

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_DOMAIN=test.com

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

这是我的登录论坛

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">{{ __('Login') }}</div>

                <div class="card-body">
                    <form method="POST" action="{{ route('login') }}">
                        {{ csrf_field() }}
                        <div class="form-group row">
                            <label for="name" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>

                            <div class="col-md-6">
                                <input id="name" type="name" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>

                                @error('name')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>

                            <div class="col-md-6">
                                <input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">

                                @error('password')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <div class="col-md-6 offset-md-4">
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>

                                    <label class="form-check-label" for="remember">
                                        Remember Me
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group row mb-0">
                            <div class="col-md-8 offset-md-4">
                                <button type="submit" class="btn btn-primary">
                                    Login
                                </button>

                                @if (Route::has('password.request'))
                                    <a class="btn btn-link" href="{{ route('password.request') }}">
                                        Forgot Your Password?
                                    </a>
                                @endif
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

这里是web.php

<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', [\App\Http\Controllers\WebsiteIndex::class, 'index'])->name('website.home');

Route::get('categories', [\App\Http\Controllers\WebsiteIndex::class, 'categories'])->name('website.categories');

Route::get('products/{category_id}', [\App\Http\Controllers\WebsiteIndex::class, 'products'])->name('website.products');

Route::get('product/{product_id}', [\App\Http\Controllers\WebsiteIndex::class, 'product'])->name('website.product');

Route::get('contacts', function () {
    return view('website.contact');
})->name('website.contact');



Route::get('about', function () {
    return view('website.about');
})->name('website.about');


Route::get('test', function () {
    return view('playground.index');
});

Route::resource('admin/producttypes', \App\Http\Controllers\ProductTypeController::class)->middleware('auth');;
Route::resource('admin/products', \App\Http\Controllers\ProductController::class)->middleware('auth');;

if (file_exists(app_path('Http/Controllers/LocalizationController.php'))) {
    Route::get('lang/{locale}', [\App\Http\Controllers\LocalizationController::class, 'lang']);
}


Auth::routes(['register' => false]);
Route::get('password/change', [\App\Http\Controllers\ChangePasswordController::class, 'index']);
Route::post('password/change', [\App\Http\Controllers\ChangePasswordController::class, 'store'])->name('change.password');;


Route::get('/admin', [App\Http\Controllers\HomeController::class, 'index'])->name('home');

原来是服务器端问题,因为服务器阻止了所有传入的 POST 请求。由托管服务提供商修复。