Laravel 5.6与邮递员一起无法使用API​​路线

时间:2018-07-18 13:57:16

标签: php laravel api postman

邮递员的testo给我一个错误时,我在拉拉维尔(Laravel)测试护照时遇到问题。

"message": "",
    "exception": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException",
    "file": "/data/www/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php",
    "line": 179,

routes / api.php

Route::group([
    'prefix'        => 'api',
    'middleware'    => ['auth.api']
], function () {
    Route::post('details', 'API\UserController@details');
});

UserController.php

    public function details()
{
    dd("Ijdsijds");
    $user = Auth::user();
    return response()->json(['success' => $user], $this->successStatus);
}

kernel.php

   protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
            'cors' => [
                \Barryvdh\Cors\HandleCors::class,
            ]
        ],
    ];

VerifyCRFSToken.php

protected $except = [
        //'authenticate'
        '/api/*'
    ];

我要去哪里错了?路线列在路线:列表中

1 个答案:

答案 0 :(得分:0)

当您使用routes/api.php时,它是无状态的,因此不会获得任何会话值(此处为Auth)。

获取价值要么使用Passport Helpful link

或使用JWT