php - Laravel POST 方法作为 GET 方法发送。代码 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.
解决方案
检查标头,POST 请求http://www.aouacc.net/aunthinticate
返回一个301 Mover Permanently
标头,这会触发重定向到 https 版本。由于显然您没有在代码中设置该重定向,因此它可能已设置在服务器级别。更改您的路线,以便他们使用https://www.aouacc.net
而不是http://www.aouacc.net
.
推荐阅读
- pytorch - 为什么当张量大小不同时,torch.Tensor减法效果很好?
- angular - 如何为ngrx/data提供初始状态?
- rust - 构建 Substrate 期间的编译问题
- kubernetes - Kubernetes 容器重启后的环境变量值
- android - 流没有捕获 AbortFLowException
- javascript - 无法使用 null || 执行验证 未定义 || "" 值
- node.js - findByIdAndUpdate 模型和增量基于关闭按钮单击
- blazor - 如何使用 blazor 模板获取输入文本框的值
- react-native - 如何使用离子反应在应用程序加载时打开模式弹出窗口
- mysql - MySQL,是否应该创建一个字段来存储关系表计算?