[英]The GET method is not supported for this route. Supported methods: POST. in laravel 8
[英]After uploading Laravel 6.0 project I am getting "The GET method is not supported for this route. Supported methods: POST." error
该项目正在我的本地服务器上运行,没有错误。 但是在将项目上传到服务器后,我得到了
此路由不支持 GET 方法。 支持的方法:POST。
错误。 我使用了 Laravel 6.0
api.php:
Route::post('rates', 'ShippoController@rates');
控制器:
public function rates(Request $request){
$validatedData = $request->validate([
'email' => 'required|email',
'name' => 'required',
'token' => 'required',
]);
try{
$carts = Cart::whereToken($request->token)->get();
if (count($carts) == 0){
return response()->json([
'status' => 0,
'message' => 'Invalid cart token.',
], Response::HTTP_NOT_IMPLEMENTED);
}
...
return response()->json([
'status' => 1,
'data' => $data,
], Response::HTTP_OK);
}
catch (\Exception $e){
return response()->json([
'status' => 0,
'message' => $e->getMessage()
], Response::HTTP_BAD_GATEWAY);
}
}
您的问题是http://canvas.safedevs.com/重定向到http s ://canvas.safedevs.com/ 。 发生重定向时,POST 将转换为 GET,并且发布数据丢失。
将请求发送到端点的 HTTPS 版本,它应该可以正常工作。
Insomnia显然具有禁用自动跟随重定向的功能,您可以考虑启用该功能。 它会让您更好地了解此类问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.