Обновление: запуск php artisan route:clear
устраняет проблему, но только частично. После того, как я запустил команду и успешно использовал API, вызываемый мной маршрут снова исчезает из кэша списка маршрутов и вынуждает меня снова выполнить команду. Я понятия не имею, почему это происходит.
Я пытаюсь использовать настроенный API Laravel, но могу по какой-то причине использовать только один из трех доступных маршрутов, два других drop 404.
Route::post('/login', 'API\UserController@login'); //this works
Route::group(['middleware' => ['auth:api']], function () {
Route::post('/roles/all', 'API\RoleController@getAll'); //this doesn't work - error 404
Route::post('/permissions/all', 'API\PermissionController@getAll'); //this doesn't work - error 404
});
Маршруты указывают на правильное место, функции существуют, и вызов, который я делаю через Почтальон, имеет правильные параметры (пример URL: 'http://localhost: 8000 / api / role / all ', вызов GET, токен авторизации в поле Авторизация).
Также не имеет значения, помещаю ли я маршруты внутри или вне промежуточного программного обеспечения (на случай, если что-то было делать с токеном oauth2 или самим промежуточным программным обеспечением, имеющим проблемы).
Вот пример одной из функций, которые я пытаюсь вызвать:
public function getAll()
{
$role = Role::all();
return response()->json(['role' => $role], 200);
}
Редактировать: вот вывод php Ремесленный маршрут: список
+--------+----------+----------------------------------------------------------+-----------------------------------+---------------------------------------------------------------------------+------------+
| Domain | Method | URI | Name | Action
| Middleware |
+--------+----------+----------------------------------------------------------+-----------------------------------+---------------------------------------------------------------------------+------------+
| | POST | api/login | | App\Http\Controllers\API\UserController@login
| api |
| | GET|HEAD | oauth/authorize | passport.authorizations.authorize | Laravel\Passport\Http\Controllers\AuthorizationController@authorize | web,auth |
| | DELETE | oauth/authorize | passport.authorizations.deny | Laravel\Passport\Http\Controllers\DenyAuthorizationController@deny | web,auth |
| | POST | oauth/authorize | passport.authorizations.approve | Laravel\Passport\Http\Controllers\ApproveAuthorizationController@approve | web,auth |
| | POST | oauth/clients | passport.clients.store | Laravel\Passport\Http\Controllers\ClientController@store | web,auth |
| | GET|HEAD | oauth/clients | passport.clients.index | Laravel\Passport\Http\Controllers\ClientController@forUser | web,auth |
| | PUT | oauth/clients/{client_id} | passport.clients.update | Laravel\Passport\Http\Controllers\ClientController@update | web,auth |
| | DELETE | oauth/clients/{client_id} | passport.clients.destroy | Laravel\Passport\Http\Controllers\ClientController@destroy | web,auth |
| | POST | oauth/personal-access-tokens | passport.personal.tokens.store | Laravel\Passport\Http\Controllers\PersonalAccessTokenController@store | web,auth |
| | GET|HEAD | oauth/personal-access-tokens | passport.personal.tokens.index | Laravel\Passport\Http\Controllers\PersonalAccessTokenController@forUser | web,auth |
| | DELETE | oauth/personal-access-tokens/{token_id} | passport.personal.tokens.destroy | Laravel\Passport\Http\Controllers\PersonalAccessTokenController@destroy | web,auth |
| | GET|HEAD | oauth/scopes | passport.scopes.index | Laravel\Passport\Http\Controllers\ScopeController@all | web,auth |
| | POST | oauth/token | passport.token | Laravel\Passport\Http\Controllers\AccessTokenController@issueToken | throttle |
| | POST | oauth/token/refresh | passport.token.refresh | Laravel\Passport\Http\Controllers\TransientTokenController@refresh | web,auth |
| | GET|HEAD | oauth/tokens | passport.tokens.index | Laravel\Passport\Http\Controllers\AuthorizedAccessTokenController@forUser | web,auth |
| | DELETE | oauth/tokens/{token_id} | passport.tokens.destroy | Laravel\Passport\Http\Controllers\AuthorizedAccessTokenController@destroy | web,auth |
| | POST | telescope/telescope-api/cache | | Laravel\Telescope\Http\Controllers\CacheController@index | telescope |
| | GET|HEAD | telescope/telescope-api/cache/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\CacheController@show | telescope |
| | POST | telescope/telescope-api/commands | | Laravel\Telescope\Http\Controllers\CommandsController@index | telescope |
| | GET|HEAD | telescope/telescope-api/commands/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\CommandsController@show | telescope |
| | POST | telescope/telescope-api/dumps | | Laravel\Telescope\Http\Controllers\DumpController@index | telescope |
| | POST | telescope/telescope-api/events | | Laravel\Telescope\Http\Controllers\EventsController@index | telescope |
| | GET|HEAD | telescope/telescope-api/events/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\EventsController@show | telescope |
| | POST | telescope/telescope-api/exceptions | | Laravel\Telescope\Http\Controllers\ExceptionController@index | telescope |
| | PUT | telescope/telescope-api/exceptions/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\ExceptionController@update | telescope |
| | GET|HEAD | telescope/telescope-api/exceptions/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\ExceptionController@show | telescope |
| | POST | telescope/telescope-api/gates | | Laravel\Telescope\Http\Controllers\GatesController@index | telescope |
| | GET|HEAD | telescope/telescope-api/gates/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\GatesController@show | telescope |
| | POST | telescope/telescope-api/jobs | | Laravel\Telescope\Http\Controllers\QueueController@index | telescope |
| | GET|HEAD | telescope/telescope-api/jobs/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\QueueController@show | telescope |
| | POST | telescope/telescope-api/logs | | Laravel\Telescope\Http\Controllers\LogController@index | telescope |
| | GET|HEAD | telescope/telescope-api/logs/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\LogController@show | telescope |
| | POST | telescope/telescope-api/mail | | Laravel\Telescope\Http\Controllers\MailController@index | telescope |
| | GET|HEAD | telescope/telescope-api/mail/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\MailController@show | telescope |
| | GET|HEAD | telescope/telescope-api/mail/{telescopeEntryId}/download | | Laravel\Telescope\Http\Controllers\MailEmlController@show | telescope |
| | GET|HEAD | telescope/telescope-api/mail/{telescopeEntryId}/preview | | Laravel\Telescope\Http\Controllers\MailHtmlController@show | telescope |
| | POST | telescope/telescope-api/models | | Laravel\Telescope\Http\Controllers\ModelsController@index | telescope |
| | GET|HEAD | telescope/telescope-api/models/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\ModelsController@show | telescope |
| | POST | telescope/telescope-api/monitored-tags | | Laravel\Telescope\Http\Controllers\MonitoredTagController@store | telescope |
| | GET|HEAD | telescope/telescope-api/monitored-tags | | Laravel\Telescope\Http\Controllers\MonitoredTagController@index | telescope |
| | POST | telescope/telescope-api/monitored-tags/delete | | Laravel\Telescope\Http\Controllers\MonitoredTagController@destroy | telescope |
| | POST | telescope/telescope-api/notifications | | Laravel\Telescope\Http\Controllers\NotificationsController@index | telescope |
| | GET|HEAD | telescope/telescope-api/notifications/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\NotificationsController@show | telescope |
| | POST | telescope/telescope-api/queries | | Laravel\Telescope\Http\Controllers\QueriesController@index | telescope |
| | GET|HEAD | telescope/telescope-api/queries/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\QueriesController@show | telescope |
| | POST | telescope/telescope-api/redis | | Laravel\Telescope\Http\Controllers\RedisController@index | telescope |
| | GET|HEAD | telescope/telescope-api/redis/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\RedisController@show | telescope |
| | POST | telescope/telescope-api/requests | | Laravel\Telescope\Http\Controllers\RequestsController@index | telescope |
| | GET|HEAD | telescope/telescope-api/requests/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\RequestsController@show | telescope |
| | POST | telescope/telescope-api/schedule | | Laravel\Telescope\Http\Controllers\ScheduleController@index | telescope |
| | GET|HEAD | telescope/telescope-api/schedule/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\ScheduleController@show | telescope |
| | POST | telescope/telescope-api/toggle-recording | | Laravel\Telescope\Http\Controllers\RecordingController@toggle | telescope |
| | POST | telescope/telescope-api/views | | Laravel\Telescope\Http\Controllers\ViewsController@index | telescope |
| | GET|HEAD | telescope/telescope-api/views/{telescopeEntryId} | | Laravel\Telescope\Http\Controllers\ViewsController@show | telescope |
| | GET|HEAD | telescope/{view?} | telescope | Laravel\Telescope\Http\Controllers\HomeController@index | telescope |
+--------+----------+----------------------------------------------------------+-----------------------------------+---------------------------------------------------------------------------+------------+