[英]Laravel 5 MethodNotAllowedHttpException in RouteCollection.php line 219
[英]Laravel 5: MethodNotAllowedHttpException in RouteCollection.php line 219
当我尝试访问页面时,出现MethodNotAllowedHttpException。 这曾经奏效,但不知道我做了什么来打破它。
routes.php
Route::post('api', ['middleware' => 'api', 'uses' => 'DeviceController@api']);
DeviceController.php
public function api()
{
return view('api');
}
api.blade.php(我更改了api.blade.php以排除它是问题的根源。)
<?php echo 'test'; ?>
app / Http / kernal.php
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
],
'api' => [
'throttle:60,1',
'auth:api',
],
];
config / auth.php
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'devices',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'devices' => [
'driver' => 'eloquent',
'model' => App\Device::class,
],
],
app / Providers / RouteServiceProvider.php
public function map(Router $router)
{
$router->group([
'namespace' => $this->namespace,
], function ($router) {
require app_path('Http/routes.php');
});
}
我正在使用邮递员模拟POST请求。
我解决了这个问题。 尝试使用http时,我强制与.htaccess文件建立安全连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.