douwen9540 2018-08-16 20:08
浏览 361
已采纳

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

So I already looked at the answers that are related to my issue. I have a laravel application which is working great on my localhost server. Routes are working fine there. But when I uploaded my laravel application on shared hosting, only GET methods are working. When I try to use any POST request such as login to my application, it sends 405 error code. So i'll show you what is wrong when I login for example.

This is the route.

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

The controller function

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:

<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>

This is what I get from console before submitting the 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.

And this is after submitting. enter image description here

enter image description here

  • 写回答

1条回答 默认 最新

  • dougan6402 2018-08-16 20:17
    关注

    Check the headers, the POST request to http://www.aouacc.net/aunthinticate returns a 301 Mover Permanently header, which triggers a redirect to the https version. Since apparently you're not setting that redirect in your code, it might have been set at a sever level. Change your routes so they use https://www.aouacc.net instead of http://www.aouacc.net.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?