Search code examples
laravellaravel-passport

Laravel 5.5 api calls using passport going to web routes instead of api


I am building an api into an existing laravel application. I followed the tutorial in the docs adn using postman I am trying to call an endpoint but keep getting pushed into my web.php routes. In there I have the following at the bottom:

Route::get('{catchall}', ['as' => 'url', 'uses'=>'PagesController@getPage'])->where('catchall', '(.*)');

Which catches all the pages that do not have routes and sends them to a 404 page. The api calls are getting to that route and returning the 404. Why are they not hitting the api.php file first?


Solution

  • You need to add api prefix in url to call api.php, like if you have home route in api.php then call it like:

    Http://127.0.0.1:8000/api/login