【问题标题】:Laravel 5.6 php artisan route:list shwoing only api middleware why?Laravel 5.6 php artisan route:list 为什么只显示 api 中间件?
【发布时间】:2019-05-01 05:41:22
【问题描述】:

我正在尝试从 laravel5.6 制作 api,它可以工作,但两者都没有工作,我无法运行网站,因为 web 路由不起作用 在 api 中间件上的路由列表 shpwing 为什么?

$ php artisan route:list
+--------+----------------------------------------+--------------------+----------+--------------------------------------------------+------------+
| Domain | Method                                 | URI                | Name     | Action                                           | Middleware |
+--------+----------------------------------------+--------------------+----------+--------------------------------------------------+------------+
|        | GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS | api/en/v1/gettoken | gettoken | App\Http\Controllers\Api\ApiController@gettoken  | api        |
|        | GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS | api/en/v1/login    | login    | App\Http\Controllers\Api\UserController@login    | api        |
|        | GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS | api/en/v1/register | register | App\Http\Controllers\Api\UserController@register | api        |

【问题讨论】:

  • 您好,您需要将 web 路由与 api 分开。 routes/api.php 仅用于 API(使用 api 中间件),web.php 使用 Web 中间件

标签: laravel rest api


【解决方案1】:

在 routes/web.php 中写下你的路线。 api.php 中的所有路由都使用了 api 中间件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-13
    • 2018-07-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-07
    • 2019-08-01
    • 2016-03-24
    • 2020-12-18
    相关资源
    最近更新 更多