Laravel POST 方法作为 GET 方法发送。代码 405

Laravel POST method being sent as GET method. Code 405

所以我已经查看了与我的问题相关的答案。 我有一个 laravel 应用程序,它在我的本地主机服务器上运行良好。路线在那里工作正常。但是当我在共享主机上上传我的 laravel 应用程序时,只有 GET 方法有效。当我尝试使用任何 POST 请求(例如登录我的应用程序)时,它会发送 405 错误代码。 所以我会告诉你我登录时出了什么问题。

这是路线。

Route::post('authinticate',['as'=>'authinticate','uses'=>'LoginController@authenticate']);

控制器函数

public function authenticate(LoginRequest $request)
    { //$credentials = $request->only('user_name', 'password');

        $credentials = array(
            'user_name' => $request->input('username'),
             'password' => $request->input('password'),
            );


        if (Auth::attempt($credentials)) {
            // Authentication passed...
            return redirect()->route('home');
        }
        else{
            return redirect()->back()->withErrors(['message' => 'اسم المستخدم او كلمة المرور غير صحيحين.']);
        }
    }

HTML形式:

<form method="POST" action="{{ route('authinticate') }}">
                @csrf

                    <div class="form-group signIn">
                        <label for="username">اسم المستخدم</label>
                        <input type="text" name="username" placeholder="اسم المستخدم" class="form-control" id="username" value="{{ old('user_name') }}">
                    </div>
                    <div class="form-group">
                        <label for="password">كلمة المرور</label>
                        <input type="password" name="password" placeholder="كلمة المرور" class="form-control" id="password">
                        <p></p>
                        <a href="{{ route('forgot') }}" >نسيت كلمة المرور</a>
                    </div>
                    <input type="submit" class="btn btn-block btn-default btn-success" name="submit" id="submit" value="دخـــول">
                </form>

这是我在提交表单之前从控制台获得的信息。

Mixed Content: The page at 'https://www.aouacc.net/login' was loaded over a secure connection, but contains a form that targets an insecure endpoint 'http://www.aouacc.net/authinticate'. This endpoint should be made available over a secure connection.

这是提交后的结果。

检查 headers,POST 请求 http://www.aouacc.net/aunthinticate returns 一个 301 Mover Permanently header,触发重定向到https 版本。由于显然您没有在代码中设置重定向,因此它可能是在服务器级别设置的。更改您的路线,以便他们使用 https://www.aouacc.net 而不是 http://www.aouacc.net