新的laravel路线不适用于任何方法
我的控制器代码:新的laravel路线不适用于任何方法,laravel,Laravel,我的控制器代码: class MobileLoginController extends Controller{ public function SendMail(){ echo 'test'; } public function otherroute(){ echo 'testotherroute'; } } My web.php Route::post('/mobilesendshopmail','MobileLoginCo
class MobileLoginController extends Controller{
public function SendMail(){
echo 'test';
}
public function otherroute(){
echo 'testotherroute';
}
}
My web.php
Route::post('/mobilesendshopmail','MobileLoginController@SendMail');
Route::post('/mobiletestotherroute','MobileLoginController@otherroute');
我也将其添加到了VerifyCsrfToken
protected $except = [
'/mobilesendshopmail',
'/mobiletestotherroute',
..]
其他路由正在运行,例如[mobiletestotherroute
]
怎么了?
但是,如果我将route sendmail的内容放在route otherroute中,它就会工作
您还可以通过将其uri
添加到$except
VerifyCsrfToken中间件的属性:
所以这只是我面临的一些愚蠢的情况lol,问题是我与github发生冲突,因为当我检查我的本地代码以获取VerifyCsrf时,我有/mobilesendshopmail的路由,但是当我拉到我们的生产服务器时,我没有拉错,但我的VerifyCsrf没有被添加,因为它列在我的.gitignore jeez上。你能告诉我你遇到了什么样的错误吗?我得到了419,但我已经添加了验证路径。你能再次检查我的帖子吗?我已经在VerifyCsrfToken中添加了路由:在开始时不带“/”重试我已经尝试了,带/,不带/,整个url,myurl.com/mobilesendshopmail您是否检查了\App\Http\Middleware\VerifyCsrfToken::class是否加载到您的App\Http\kernel.php中?是的,添加了。这里是粗略的部分,其他路由正在工作,它们有相同的代码到新路由不工作。
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'mobilesendshopmail',
'mobiletestotherroute',
];
}