参考文档定义App\Http\Middleware\VerifyCsrfToken.php的$except也没有解决post请求的问题。奇怪的是备注掉app\Http\Kernel.php的$middleware中的\App\Http\Middleware\VerifyCsrfToken::class之后依然报错MethodNotAllowedHttpException in RouteCollection.php line 218路由定义如下:
Route::group(['prefix' => 'api/caplus'],function(){
Route::resource('public', 'CaPlusPublicController');
Route::get('/comments','CaPlusPublicController@comments') -> name('comments');
Route::get('/wxLogin','CaPlusPublicController@wxLogin') -> name('wxLogin');
Route::post('/postSubmit','CaPlusPublicController@postSubmit') -> name('postSubmit');
});
VerifyCsrfToken.php:
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'api/*'
];
}
添加回答
举报
0/150
提交
取消