postgresql 登录功能在LARAVEL的本地服务器上工作,但不在Live服务器上工作

14ifxucb  于 10个月前  发布在  PostgreSQL
关注(0)|答案(1)|浏览(117)

我已经将我的项目部署在一个实时服务器上;但是,它没有按预期运行。当我单击登录按钮时,它将我重定向到本地IP地址。这个问题的原因可能是什么?这里是我的代码片段供参考:
这是我的登录表单:

<!-- Form -->

<form class="form-horizontal mt-3 form-material" id="loginform" action="https://samplesite.edu.jp/school_portal/login-user" method='POST'>
@if(Session::has('success'))
 <div class="alert alert-success">{{Session::get('success')}}</div>
@endif
@if(Session::has('fail'))
 <div class="alert alert-danger">{{Session::get('fail')}}</div>
@endif
@csrf

<!-- The rest of the form (email and app code)-->
</form>

字符串
这是我的web.php中的路由:

Route::post('/login-user',[LoginController::class, 'loginUser'])->name('login-user');


这是我控制器上的代码:

public function loginUser(Request $request)
{

    $request->validate([
        'email' => 'required|email',
        'application_code' => 'required|min:5|max:20'
    ]);

    $user = UserModel::where('email', $request->email)
                    ->where('application_code', $request->application_code)
                    ->first();
 
    if ($user) {

        $request->session()->put('loginId', $user->seq_id);

        return redirect('dashboard');
    } else {

        return back()->with('fail', 'The email and application code does not match');
    }
}


点击登录按钮后,它将我重定向到这个网址:
http://192.168.7.101/school_portal/login
我的表格上的错误是“请先登录”

hivapdat

hivapdat1#

我在这里做了一个大胆的猜测,但我认为你没有改变你的.env文件中的APP_URL参数。你需要把它改为https://samplesite.edu.jp/school_portal/。你也应该像在你的问题的评论中提到的那样使用路由助手来生成URL。
您现在拥有:

<form action="https://samplesite.edu.jp/school_portal/login-user" method="POST">

字符串
您应该使用:用途:

<form action="{{ route('login-user') }}" method="POST">


现在您可以检查生成的路由是否是正确的URL,如果是,重定向也应该是可以的。

相关问题