Webtect
Webtect

Reputation: 839

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?

Upvotes: 1

Views: 226

Answers (2)

Palak Jadav
Palak Jadav

Reputation: 1264

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

Upvotes: 1

Ramesh Navi
Ramesh Navi

Reputation: 763

First, test your API endpoints using POSTMAN.

Request URL should be something like http://127.0.0.1:3000/api/login. Remember /api/ in the path

Use Accept:application/json in request header.

enter image description here

Upvotes: 1

Related Questions