簡體   English   中英

Laravel 5:RouteCollection.php第219行中的MethodNotAllowedHttpException

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM